angular 1 vs Angular 2

angular 1 vs Angular 2


Surprisingly, Angular 2 feels like a new language: A different style of programming more efficient than before. Angular 2 was built with mobile support in mind. It is a completely reworked language, which includes breaking changes in the following areas.

  • Directives
    The directives are simply more flexible and affordable than before.
    • Direct binding to HTML element’s attributes ( and DOM events)
      This new method eliminates the need for a lot of directives, like ng-hrefng-srcng-click etc. directly uses the valid HTML element properties like href, src and DOM events like click. So the list of directives in Angular 2 is much shorter compared to Angular 1.x.
    • CamelCase syntax for built-in directives
      camel Casing makes code more natural to read (without ‘slur’). For example, ng-model is now ngModel. Underscores ( _ ) and hyphens ( – ) are harder to type than capitals, since they are so far away from the home row.
    • Structural directives syntax changed
      In Angular 2 Structural directives are prefixed with asterisk(*). ie. ng-repeat is written as *ngFor.

  • Components
    The most important changes are the introduction of Components, which manages views. The purpose of the Angular 2 application architecture is to create loosely coupled Components ( independent reusable piece of UI). Components makes it easier to understand, test, and maintain the code. Angular 1.x Controllers and $scope are no longer used. It is not that terrible, because Angular Components are actually, directives with a template.
  • Service
    In Angular 2, we can only define a service through class. In Angular 1.x we can define a service either through Factory, Service, Provider, Constant or Values.

Learn More
If you’re looking for comprehensive Angular tutorials and learning opportunities, check out our various Angular training options.

Leave a Reply