Angular2 如何多次触发子组件的 ngOnInit Posted on 2016-03-29 | 通常子组件加载后只会执行一次ngOnInit,不利于子组件的自我更新,但设法使子组件从Dom中移除后重建就可以多次触发ngOnInit。1<person *ngIf="show"></person> 12345class PersonComponent { ngOnInit() { // triggered if show is available }} 像这种带星号的指令就是Angular2中一种模板语法糖,可以管控组件的生命周期。 Post author: Micooz Lee Post link: https://apporz.com/2016/03/29/angular2-multiple-ngoninit/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.