What is the difference between annotation and decorator in Angular 2?
Annotation | Decorator |
---|---|
Used by Traceur compiler | Used by Typescript compiler |
Annotation creates the attribute ‘annotations’ that stores arrays and pass metadata to the constructor of the annotated class. | It is a function that gets the object that needs to be decorated (or constructed). They can change the attributes of the object as necessary. |
Annotations are hard-coded | Not hard-coded |
Example – import {Component} from 'angular2/angular2'; |
Example - import {ComponentAnnotation as Component} from 'angular2/angular2'; |
BY Best Interview Question ON 29 Apr 2019