The AngularJS project is relatively new. It was first introduced in 2009. During this time, several versions were released and a dense community has gathered around the product. The success of the project was largely determined by its parent, Google. Good geeks treat the releases of the corporation with special trepidation, especially when it comes to tools for developers. This time it turned out the same. I won't go into the technical jungle, but I'd rather tell you right away why this framework hooked a lot of developers. On the one hand, AngularJS has a fairly low barrier to entry compared to many similar solutions. On the other hand, the documentation is slightly controversial. It seems to be well structured, there are code examples, but some things are extremely poorly covered. You will have to deal with them on your own, studying the sources or requesting comments from colleagues in the shop. For example, Misko Hevery's comments on StackOverflow and watching an AngularJS video can help you understand how scopes work. Angular developers have moved away from the traditional idea: "HTML is the enemy and must be fought against." Instead, they decided to naturally extend the markup language by introducing additional directives. The more tests cover the code, the less chance of unexpected surprises. Angular developers agree with this approach, so the framework out of the box is friendly to writing tests. To output something to the content of an object, you do not need to write bulky style constructions or something like that in the template. It is enough to enclose the expression in double curly braces, and that's it, the data will be processed.
Directives are one of the key features of Angular. They allow the developer to describe the behavior of individual elements and extend the HTML syntax. Angular comes with only a basic set of directives. However, no one prevents us from expanding it with our own developments. Correctly created directives can be used in other projects as well. Some developers even practice putting their collections of components in the public domain. I said for a reason that directives are one of the key features. Novice developers often ignore this thought and begin to trick things in their own way - they modify the DOM directly. In no case should this be done. Why? Firstly, this is what the sacred commandments of Angular say, and secondly, the developer is deprived of goodies like reusing his own work, simple code maintenance, and so on. There are many negative reviews about Angular's performance. According to some claims, the performance of the framework is not good enough and not suitable for serious applications. For example, you can often come across examples whose authors demonstrate the unsuitability of the framework for processing tens of thousands of objects. "Angular slows down with its advanced bindings!" - ardent opponents shout. Upon closer examination of the examples, it becomes obvious that the problem is far-fetched and their authors did not bother to read the documentation and supporting materials from the official blog to the end. To dispel the performance myths once and for all, let's take a look at the mysterious essence of scope. Scope is not a model, and you shouldn't try to make one out of it. Nothing good will come of it.
The Angular manual clearly states that a model means any array of data, and a scope can contain a reference to a model. You don't need to push all the data from the model to the scope. Yes, in such a context it is convenient to manipulate them, but you will not get any benefit, only brakes. You should not consider everything said to be a banal workaround and excuse from the Angular developers. This is Angular architecture and must be reckoned with. Moreover, do not forget about the MVVM pattern. In addition to the traditional "model" entity, it highlights the "model-view", and in this case, scope is the model-view, which means that it must contain the data that you want to display. Bootstrapping an Angular application is done using the ngApp directive. This method is suitable in most cases, but if you wish, you can do everything with pens. In our example, we will go the simple way, that is, we will use the ngApp directive, specifying it in the root element of the page. After declaring this directive, the following will happen: an injector will be created (a mechanism used to obtain instances of objects provided by the provider, load modules, and so on), which will be used to inject dependencies within the application; injector will form a global scope in the context of our application's model; Angular will start processing the DOM tree from the element where the ngApp directive was declared. During this process, all found bindings will be created and found directives will be executed. After the download is complete, the real tracking of all bindings begins. If any events happen (for example, a banal mouse click or text input), then Angular will immediately update the view and bindings. Let's spread out all this text on the shelves:
- utmost simplicity of technology, the possibility of quick learning;
- declarative approach;
- the framework is test-friendly;
- the presence of directives as the main feature;
- good performance.
So why AngularJS Development? From my point of view, AngularJS has become an amazing combination of low barriers to entry and rich feature set. It will take about an hour of free time to start writing small applications with it help. At the same time, it will take months to learn and use all its features. So far, there has not been a single front-end problem that a developer could not solve using this framework. Definitely, AngularJS turned out to be a high-quality and interesting solution that should be used in your projects. Once again, Google was able to surprise us with the release of a well thought out product. It cannot be said that he turned out to be ideal, but he can cope with the tasks assigned to him, and this is the most important thing. At this point, I want to thank you for reading the article and wish you look in new way at the world of JS development.