When I took Angular 2 to build my application, I still had my doubts to go with Angular 2 or some other framework. But after some research, I decided to go with Angular 2. It gives the ability to make Single Page Application in a perfect and viable way. Here are some others reasons / advantages I liked:
1. TypeScript : Unlike javascript, typescript is type safe, that means, it can generate errors at compile time only.
TypeScript is an extension of ECMAScript, in fact:
TypeScript = ES6 + Types + Annotations
Type script is purely Object oriented tries to extend object oriented javascript. It is quite common to work with classes and modules in JavaScript, but it requires some amount of boilerplate code. And it is not really easy to be read. TypeScript allows to write class, interface, and module-statements just like in Java or ASP .Net. which is by far easier, It Offers a “compiler” that can convert to JavaScript-equivalent code, that makes writing that foundation easier. Not only that, typescript can transpile to any version of javascript code, whether it be ES6, ES5 and so on.
2. Speed and Performance : Angular 2 supports Lazy loading. By that we mean, you don’t need to load the complete app at once. Rather, modules can be loaded dynamically whenever there is a requirement, or we shall say, whenever the new page is loaded.
Also, Angular 2 supports AOT compilation. In which, you can compile your javascript code Ahead Of Time unlike Just in time compilation, where the javascript is compiled on browser. This saves a lot of time and boosts the performance by a greater margin.
3. Uses the valid HTML, DOM : Unlike Angular 1, Angular 2 directly uses the valid HTML DOM element properties and events. like hidden
,href
, src
. In angular 1 we used to have ng-href
, ng-src
, ng-hidden
4. Modular: When a programming language supports modularity, its always good to maintain the code. Everything in Angular 2 is module based, defined in @NgModule.And because of this modularity with Object Oriented concepts, it is easier for Java based programmers to learn a new Javascript framework. So there is no more $Scope and controllers what we have in angular 1.
5 . Way of Bootstrapping Application : Unlike Angular 1 there we had two ways to start our angular application One using ng-app
attribute and other via code. In Angular2 there is only one way to bootstrap application, there is no more ng-app
attribute. The only way to bootstrap angular application is via code i.e as follows:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { AppModule } from './app/app.module'; platformBrowserDynamic().bootstrapModule(AppModule);
6. Dependency injection is enhanced : Angular 2 follows the technique called dependency injection.Not only that, Angular has its own Dependency injection framework. DI makes working with components so much simpler and helps in testing your code. We inject dependencies in Angular 2 by using @injectable() decorator like:
@Injectable() class UsefulService { } @Injectable() class NeedsService { constructor(public service: UsefulService) {} } const injector = ReflectiveInjector.resolveAndCreate([NeedsService, UsefulService]); expect(injector.get(NeedsService).service instanceof UsefulService).toBe(true);
More blogs are on its way which would contain more information about Angular2 and its implementation of code.
Like & Share it!
Reblogged this on ashutomar.
Reblogged this on pranjut.
Suggestions
post to reddit after your writing skills are well honed not before
pay attention to your headline and first sentence
ask yourself why someone would want to read your post
hope that helps
Hey Joe,
Thank you for your suggestion. I have updated the beginning of the blog as you have advised. If you think, you could give me some more suggestion I would love to improve on that as well.
[…] via When I took Angular 2 to make my practical application — Knoldus […]
[…] via When I took Angular 2 to ramp up my covering — Knoldus […]
Your article is very amazing… Thanks for sharing your angular2 information…