fixture.detectChange开始单步调试,如何执行到Directive的ngOnChange钩子
生活随笔
收集整理的這篇文章主要介紹了
fixture.detectChange开始单步调试,如何执行到Directive的ngOnChange钩子
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
this._tick里調(diào)用this.changeDetectorRef.detectChanges():
首先從RootViewRef開始檢測:
context里能看到Component的數(shù)據(jù):
renderComponentOrTemplate:
refreshView里會調(diào)用init和check hook:
/*** Executes post-order init and check hooks (one of AfterContentInit, AfterContentChecked,* AfterViewInit, AfterViewChecked) given a view where there are pending init hooks to be executed.* @param lView The LView where hooks are defined* @param hooks Hooks to be run* @param initPhase A phase for which hooks should be run* @param nodeIndex 3 cases depending on the value:* - undefined: all hooks from the array should be executed (post-order case)* - null: execute hooks only from the saved index until the end of the array (pre-order case, when* flushing the remaining hooks)* - number: execute hooks only from the saved index until that node index exclusive (pre-order* case, when executing select(number))*/ function executeInitAndCheckHooks(lView, hooks, initPhase, nodeIndex) {ngDevMode &&assertNotEqual(initPhase, 3 /* InitPhaseCompleted */, 'Init pre-order hooks should not be called more than once');if ((lView[FLAGS] & 3 /* InitPhaseStateMask */) === initPhase) {callHooks(lView, hooks, initPhase, nodeIndex);} }使用Directive實(shí)例調(diào)用hook:
ngOnChanged hook被調(diào)用的前提是,從getSimpleChangesStore返回的simpleChangesStore里的current字段不為空:
更多Jerry的原創(chuàng)文章,盡在:“汪子熙”:
總結(jié)
以上是生活随笔為你收集整理的fixture.detectChange开始单步调试,如何执行到Directive的ngOnChange钩子的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 单冷空调比冷暖耗电吗
- 下一篇: fixture.detectChange