In Angular 1.x,.
Stayed Informed - 13 Best Advantages for Angular 2
Stayed Informed - 13 Best Advantages for Angular 2
According to Angular2 Doc, “The ngOnInit is called right after the directive's data-bound properties have been checked for the first time, and before any of its children have been checked. It is invoked only once when the directive is instantiated.”
import { Directive, Input } from '@angular/core'; @Directive({ selector: '[ngInit]' }) class NgInit { @Input() ngInit; ngOnInit() { if(this.ngInit) { this.ngInit(); } } }
In template as following,
<div * <div *</div> <div *</div> </div>
I hope you are enjoying with this post! Please share with you friends!! Thank you!!!
You Might Also Like