AfterViewInit
一個生命週期鉤子,會在 Angular 完全初始化了元件的檢視後呼叫。 定義一個 ngAfterViewInit()
方法來處理一些額外的初始化任務。
A lifecycle hook that is called after Angular has fully initialized a component's view. Define an ngAfterViewInit()
method to handle any additional initialization tasks.
interface AfterViewInit {
ngAfterViewInit(): void
}
實現類別
參見
方法
一個回呼(Callback)方法,它會在 Angular 完成了元件檢視的初始化邏輯之後立即呼叫。 在檢視初始化完成之後,它只會呼叫一次。 A callback method that is invoked immediately after Angular has completed initialization of a component's view. It is invoked only once when the view is instantiated. |
引數沒有引數。 返回值
|
使用說明
下列程式碼片段展示了元件如何實現該介面,以定義自己的檢視初始化邏輯。
The following snippet shows how a component can implement this interface to define its own view initialization method.
@Component({selector: 'my-cmp', template: `...`})
class MyComponent implements AfterViewInit {
ngAfterViewInit() {
// ...
}
}