Moving to Angular 5? Find out Yay or Nay!

07 / Nov / 2017 by Nidhi Choudhary 0 comments

AngularJS is quickly evolving and we have witnessed two major updates in the past 14 months. Now, this popular JavaScript framework has set a new milestone with its major release of Angular 5.0 on November 1, 2017. The progressive web apps and material design powered by Google will be however available in the next few days.

The all-new Angular 5 has exciting new features and fixes to previous bugs aimed at making Angular more compact, simplify its use and reduce the code size. 

Here is the breakdown of all the new changes that Angular 5 brings to the table:

Build optimizer:

The all-new Angular 5 comes with a build optimizer by default. It is a tool that performs additional optimizations on builds, including better tree shaking. It is a command-line tool which decreases the size of the application by chucking away the waste lines of code or code not required. This will ultimately improve or increase the boot speed of the application for the end user.

Material Design components are more compatible:

With Angular 5, the material design components have become more user-friendly with server-side rendering. However, there are certain issues that Google is still fixing. 

Progressive Web Apps:

Progressive Web Apps deliver a rich user experience for all the mobile devices making them more engaging, reliable and fast. PWA is an allied between Mozilla and Google which aims at developing a browser-based application providing a native-like experience.

In the new version of Angular, Google has given an attention to making it easier for development teams to build PWA and this allows the apps to get cached in the browser. However, Google is working on building support for making CLI (Command in Line ) more capable. “We’re trying to find the right set of defaults so that it just would be the default option for most developers, for both desktop and mobile web,” said Brad Green, a Google engineering director. 

Improving the compiler:

The compiler is an essential part of the Angular framework, which has been improved with the latest version of Angular and is now being operated as TypeScripts transform to enable faster builds and rebuilds. Moreover, it will now support the incremental assembling way better than before. 

ReflectivesInjector replaced by StaticInjector:

The ReflectivesInjector has been replaced by StaticInjector so as to eliminated more polyfills, which as a result will make the application size concise for developers.

Before

ReflectiveInjector.resolveAndCreate(providers);

After

Injector.create(providers);

Pipes for the international number, currency, and dates:

Angular 5 introduce pipes for the international number, currency, and dates. As a result, this will increase the standardization across browsers and eliminated the dependency on i18n polyfills by making use of their own implementation for these pipes.

HttpClient:

HTTPClient was introduced in Angular 4.3, which is now updated with the new version of Angular 5. The all-new updated version of HTTPClient is making the developers deprecate the previous @angular/http library. In order to update HttpClient, developers need to replace HttpModule with HttpClientModule from @angular/common/http in each of the modules, inject the HttpClient service, and  eliminate any map(res => res.json()) calls, which are no longer required.   

Support for Sharing Codes:

With angular 5, sharing codes between client side and server side version of the application are now much easier. For this to happen, Google has introduced Angular Universal State Transfer API and DOM support. Angular Universal provides a support to the developers in order to perform server-side rendering of Angular applications. In a way to add support to the crawlers and scrapers which does not support JavaScript, developers have to first render their Angular application on the server and then they can bootstrap the application on top of the generated HTML. This will increase the overall performance of the application.

RxJS Reactive Programming Library update:

With the new update, developers would become easy to eliminate the side effects of previous patch method of importing operators of code-splitting and tree-shaking problems. This new way of using  RxJS is called “lettable operators”. Also in addition to this, the ECMAScript module helps the RxJS to distribute the version. Moreover, the new Angular CLI will pull in ECMAScript by default.

So now instead of

import { Observable } from ‘rxjs/Observable’;
import ‘rxjs/add/operator/map’;
import ‘rxjs/add/operator/filter’;
names = allUserData
.map(user => user.name)
.filter(name => name);

The following would be used now

import { Observable } from ‘rxjs/Observable’;
import { map, filter } from ‘rxjs/operators’;
names = allUserData.pipe(
 map(user => user.name),
 filter(name => name),
);

Easy Migration for the Users:

Angular 5 have added multiple names for components and directives. This will give an advantage to the users as they can migrate easily. It is possible to add a new name in the Angular mircosyntax without breaking the existing code and this can be done by exporting a directive with multiple names.

Angular Forms:

For many applications, forms play an important part and with Angular Forms, it becomes easy for developers to take control of the validation and value updates on ‘blur’ or on ‘submit’ instead of every input event.

The Router:

There has been an addition of new lifecycle events to the router in order to allow the developers to track the router cycles from the start of running guards until completion of activation. Following are the new events:

  • ActivationStart
  • GuardsCheckEnd
  • ResolveEnd
  • ActivationEnd
  • ChildActivationEnd
  • ChildActivationStart
  • GuardsCheckStart
  • ResolveStart

Known issues with Angular 5

  • Design of the production and creation of source maps.
  • Few maps resulting in undefined sources for errors.

Angular update guide will help the development teams to learn more about Angular updates. We are waiting for Angular 6 to be released early next year. Let’s see what Angular 6 has in store for the development community.

References

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *