AngularJS Development: New Possibilities With Angular 2
Things To Get Used To In Angular 2
Second major version of Angular framework aims at gradual transitioning from using MVC (Model-View-Controller) software design pattern and switching over to the tree-like component-based architecture. Among other modifications in Angular 2, developers have to get used to and might have difficulties with, are the following:
Unlike in AngularJS, here modules, components and directives are declared by decorator functions, such as@NgModule, @Component, @Directive. Json is taken as a parameter for it.
Usual *ngFor (ng-repeat in Angular 1) doesn`t work until the BrowserModule is connected in the ‘module imports’ section.
Using Ui-router in Angular 2 can lead to bugs in the application. That is why, it is preferably to use usual Angular 2 router – @angular/router that works fine, still with some nuances. Routes are created by using functions RouterModule.forRoot (routes) when routes are an array of objects. There are two functions forRoot and forChild in application and the first one is obligatory.
Besides, if one creates a state with child states, it automatically becomes abstract. For rendering the state after getting data, a class must be written which will implement an interface Resolve. In this class there must be a method resolve, the method must return an Observable or Promise or any type of data. If method returns Promise as a catch or false, state will not be rendered.
One has to be careful not to use simple HTTP, as may be offered by the IDE. It won’t work, since the module has dependencies connected to HttpModule (native HTTP module). In order to create request headers we can use a class RequestOptions. HTTP returns data in Observables and not in a Promises as AngularJs.
Angular 2 Applications
Even though it’s been only a few months since the release of the second version of Angular, there are now a lot of Angular 2 applications, and the framework powers a number of Google projects and web applications of various companies as well:
Angular 2 Development at Mobilunity
As soon as Angular 2.0 was released, our team of developers tried to get familiar with the implemented novelties and specificities of the upgraded version. It turned out that the latest version really facilitates and enhances frontend development to a great extent, therefore the development team decided to apply it in the projects right away. Most of Mobilunity products powered by Angular 2 are still under development, but there is one, which has been already completed.
We’ve recently finished building Otest system for one of our customers, whose business is focused on content writing. The client requested a tool, which would test the skills and expertise of potential content writers, and help define whether the vendor is suitable for the company or not, as well as what type of tasks he or she is able to undertake. Eventually, the customer got fully designed and developed test constructor – an Angular 2 web app with the functionality allowing to :
Create various tests;
Create various types of questions and possible answers;
Randomize the questions;
Set the amount of time given for test completion;
Take a test
Otest system built with Angular 2 by Mobilunity team
Angular 2.0 is definitely worth working with. The changes introduced are there to stay, and more of them are going to be implemented. At NG-BE 2016 Angular conference in Belgium, Igor Minar – lead Angular developer at Google – already talked about the 4th and 5th versions (the 3rd one being skipped due to router naming reasons) to be released in 2017. So make use of the possibility to build mobile app with AngularJS 2 or a dynamic web application!