Converting Angular 1 to Angular 2 ngInit function

前端 未结 3 1767
感动是毒
感动是毒 2021-01-07 05:35

In angular1, we call the function ng-init based on ng-if condition. The following code represents If first div match with date && time then it will check the second

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-07 05:39

    You can use ngOnInit method in your component class but remember to implements the OnInit interface.

    Here's an example:

    @Component({
      selector: 'ramadan',
      template: `
    Ramadan
    ` }) class Ramadan implements OnInit { ngOnInit() { this.play(); } }

    You can fin more about ngOnInit here.

提交回复
热议问题