ngOnInit vs ionViewDidLoad in ionic 2 or ionic 2+

后端 未结 3 1285
借酒劲吻你
借酒劲吻你 2020-12-29 22:45

Which one will I use for initializing data and why?

ngOnInit() {
    this.type = \'category\';
    this.getData();
    this.setData();
}

ionViewDidLoad()          


        
3条回答
  •  甜味超标
    2020-12-29 23:02

    Both function works the same way, they get called when the view is initially loaded into the DOM.

    Great blog about ionic2s lifecycle hooks here.

提交回复
热议问题