p.location-badge. exported from angular2/metadata defined in angular2/src/core/metadata/directives.ts (line 848) :markdown Annotations provide the additional information that Angular requires in order to run your application. This module contains ComponentMetadata, DirectiveMetadata, and ViewMetadata annotations, as well as the Host annotation that is used by Angular to resolve dependencies. .l-main-section h2 Members .l-sub-section h3 OnInit :markdown Notify a directive when it has been checked the first time. This method is called right after the directive's bindings have been checked, and before any of its children's bindings have been checked. It is invoked only once. ``` @Directive({ selector: '[class-set]', lifecycle: [LifecycleEvent.OnInit] }) class ClassSet { onInit() { } } ``` .l-sub-section h3 OnDestroy :markdown Notify a directive whenever a ViewMetadata that contains it is destroyed. ``` @Directive({ ..., lifecycle: [LifecycleEvent.OnDestroy] }) class ClassSet { onDestroy() { // invoked to notify directive of the containing view destruction. } } ``` .l-sub-section h3 OnChanges :markdown Notify a directive when any of its bindings have changed. This method is called right after the directive's bindings have been checked, and before any of its children's bindings have been checked. It is invoked only if at least one of the directive's bindings has changed. : ``` @Directive({ selector: '[class-set]', properties: [ 'propA', 'propB' ], lifecycle: [LifecycleEvent.OnChanges] }) class ClassSet { propA; propB; onChanges(changes:{[idx: string, PropertyUpdate]}) { // This will get called after any of the properties have been updated. if (changes['propA']) { // if propA was updated } if (changes['propA']) { // if propB was updated } } } ``` .l-sub-section h3 DoCheck :markdown Notify a directive when it has been checked. This method is called right after the directive's bindings have been checked, and before any of its children's bindings have been checked. It is invoked every time even when none of the directive's bindings has changed. ``` @Directive({ selector: '[class-set]', lifecycle: [LifecycleEvent.DoCheck] }) class ClassSet { doCheck() { } } ``` .l-sub-section h3 AfterContentInit :markdown Notify a directive when the bindings of all its content children have been checked the first time (whether they have changed or not). ``` @Directive({ selector: '[class-set]', lifecycle: [LifecycleEvent.AfterContentInit] }) class ClassSet { afterContentInit() { } } ``` .l-sub-section h3 AfterContentChecked :markdown Notify a directive when the bindings of all its content children have been checked (whether they have changed or not). ``` @Directive({ selector: '[class-set]', lifecycle: [LifecycleEvent.AfterContentChecked] }) class ClassSet { afterContentChecked() { } } ``` .l-sub-section h3 AfterViewInit :markdown Notify a directive when the bindings of all its view children have been checked the first time (whether they have changed or not). ``` @Directive({ selector: '[class-set]', lifecycle: [LifecycleEvent.AfterViewInit] }) class ClassSet { afterViewInit() { } } ``` .l-sub-section h3 AfterViewChecked :markdown Notify a directive when the bindings of all its view children have been checked (whether they have changed or not). ``` @Directive({ selector: '[class-set]', lifecycle: [LifecycleEvent.AfterViewChecked] }) class ClassSet { afterViewChecked() { } } ```