IO /blog/ Angula…

Gorrion. IO /blog

Release time: December 30, 2019

Angular is a well-known framework for building Web applications. It’s great for both small and large applications, so it’s really worth learning and using. Read my article to learn how to choose a version of it –AngularJS or something else.

introduce

Angular is probably a well-known framework for building Web applications to most front-end developers. If we want to use Angular in our project, we must choose a version of it – AngularJS or something else. AngularJS – or some might prefer it. Angular 1 – Built in 2009. It gives us two-way data binding, allowing us to see changes in JavaScript automatically displayed on the UI. In addition, AngularJS directives allow us to create more separate and reusable code than ever before. In general, it makes it easier for us programmers to write applications in an MVC or MVVM architecture (sometimes referred to as the MVW architecture (Model-view-whatever). It is a step forward in testing front-end applications because its dependency injection mechanism helps simulate dependencies.

start

I have to say, I’m really obsessed with Angular. Over time, it has gained support from many developers. They created a lot of useful packages that made coding faster. As more and more things were being added to the core, the Angular team decided to create an entirely new framework. Originally, the new framework was named Angular 2. Sometimes this is an understatement, because over time the beta version was renamed Angular. Now, when people are looking for AngularJS code, they’ll probably find something related to Angular 2 or later. Higher, because Angular 4 was announced in December 2016. The creators purposely skipped # 3 to avoid confusion due to the misalignment of the router package version, which had already been released. Version 4 of Angular is backward compatible with Angular 2.

Controllers and Components

So what’s the difference between AngularJS and Angular? First, Angular is based on TypeScript, while AngularJS is based on JavaScript. TypeScript is a superset of ES6 that is backward compatible with ES5. Angular also has ES6 benefits, such as lambda operators, iterators, or reflection mechanisms. AngularJS uses the terms scope and controller. To scope a variable, you can add many variables that are visible in both the View and the Controller. AngularJS also has a rootScope concept. Variables in rootScope are available throughout the application. Angular has no concept of scope or controller. Instead, it uses a hierarchy of components as its main architectural concept. A component is a directive with a template. This is similar to the approach of ReactJS, another library for building user interfaces.

Template engine differences

AngularJS has a lot of directives, and every developer can specify new ones. Angular also has standard directives, but they are used a little differently. For example: ng-model in AngularJS means you create a bidirectional binding. If you want to create a one-way binding, you should use ng-bind. Angular only happens with ngModel, but if you would just write in. []”, you will get one-way binding. If you want to create a bidirectional binding, you must write it in: “[()]”. “[()] “. We write this because “[]” is used for property binding and “() “is used for event binding. In Angular, the names of some directives have been changed, such as ng-repeat to ngFor. When I started working on Angular 2 projects in beta, I made some common mistakes at the beginning, such as trying to use only ng-repeat or ngModel in square brackets when I wanted bidirectional binding.

What else has changed?

Of course, if Angular is a new version, you can suspect that it has some advantages over older versions. Yes, Angular has many advantages. The first is modularity. Many core functions have been moved into different modules. This resulted in a lighter and faster core, dynamic loading, asynchronous template compilation, and added support for reactive programming. After the beta, the creators added something really cool: the Angular CLI. With this package, you can easily create scaffolding for your Angular project, which will be all configured.

So AngularJS or Angular?

Want to know which version is best for you? The new version of Angular is a popular solution. Besides, it will be a better choice most of the time. Anyway, before you choose one for your new project, try answering some questions. What library do you want to use? Are they Angular compatible? Which web browsers do we want to support? (This is really important.) Angular is best if you only choose the new browser. Because it’s a forward-looking library, but don’t forget about other browsers. For IE8, you must use AngularJS version 1.3 and support IE8 or later.

conclusion

Angular is a great framework. It has many improvements in AngularJS. It’s going to become more and more popular, and I think it’s great for small apps as well as big apps, so it’s really worth learning and using. While we’re talking about Angular, I want to note that there’s also ReactJS, a smaller Angular rival that I’ll write more about in the next article.


Translated through (www.DeepL.com/Translator) (free version)