【问题标题】:Is there something similar to ionViewDidLoad in angular material?角度材料中是否有类似于 ionViewDidLoad 的东西?
【发布时间】:2018-07-18 02:49:02
【问题描述】:

我正在尝试在我的角度材质代码中使用 元素。通常使用 ionic,我填写我的打字稿以在 ionViewDidLoad() 中绘制这些画布的实际信息。但我不确定如何用有角度的材料绘制这些画布。 angular-material 中是否有类似于 ionViewDidLoad() 的替代方法?

【问题讨论】:

    标签: ionic-framework material-design angular-material


    【解决方案1】:

    Angular 提供了一些开箱即用的生命周期挂钩。也许您可以使用与ionViewDidLoad 非常相似的onInit。只要您使用 Angular 2 或更高版本,就可以使用 Angular 生命周期挂钩。

    import { OnInit } from '@angular/core';
    
    export class YourComponent implements OnInit {
    
        // implement OnInit's `ngOnInit` method
        ngOnInit() { 
            console.log('component inited'); 
        }
    
    }
    

    请注意,您必须实现 OnInit(而不是简单地在 Ionic 中添加您的组件的方法)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-04
      • 2011-01-07
      • 1970-01-01
      • 2011-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多