Wednesday, April 12, 2017

Quick reference for Angular 2 changes


Changes in Angular 2 compared to angular 1

  • Ngref= href property binding. Browser module has definition to *ngref. Any directive that changes the directive is known as structural directive
    *ngFor
  • No watchers and No digest cycle
  • Binding syntax has been changed
    • Property binding is done using [ ]
                  Element property  < Img [src] = "vehicle.imageurl">

    • Component binding
                    < Vehicle-detail [vehicle ] ="current vehicle" ></vehicle-detail>
    • Directive binding
                   <[ngclass]="{selected :isSelected}"> wing </div>
    • Event binding done using ()
    • String interpolation using { }
  • Angular 1 used to have around 70 directives. 40 of these directives has been removed
  • Service has been reduced to one
          


More about angular 2

  • Every application needs ngModule
  • Angular 2 is modular. Every app begins with one angular module
    • Es6 modules organize our application into cohesive block of application
    • Root Angular modules Import other Angular Modules, Identify components,Pipes and directives, provide services to app root injector, bootstrap a component, class to define the ngmodule
            Note: 
            Providers : provides services to app root injector


  • A service provides anything our application needs.It often shares data or functions between other Angular features, Provide services to injectors
  • Dependency injection is how we provide an instance of a class to another Angular feature.Angular has injector.Injector contains services
           

   

    • Angular Injects a service into a component
    • Angular locates the service in angular injector
    • Angular Injects the service into the constructor
    • If exists it would use it or it would use a new service


No comments:

Post a Comment