检测 ngIf 中输入的显示变化
Detect display change of input inside ngIf
我在 *ngIf
中有一个 input
:
<div *ngIf='display'>
<input number="number" />
</div>
我想检测 input
是否显示在数字指令中。这意味着当 display=true
并更改为 false
时,它应该调用指令内部的函数以及返回到 true
.
时
这是一个plunker
每次 display
从 false
变为 true
时创建 number
指令,并在 display
从 true
变为 true
时销毁假的。
对于前一种情况,您可以使用 constructor(...)
、ngOnInit()
、ngAfterViewInit()
或 ngAfterContentInit()
、
以后ngOnDestroy()
可以用
我在 *ngIf
中有一个 input
:
<div *ngIf='display'>
<input number="number" />
</div>
我想检测 input
是否显示在数字指令中。这意味着当 display=true
并更改为 false
时,它应该调用指令内部的函数以及返回到 true
.
这是一个plunker
每次 display
从 false
变为 true
时创建 number
指令,并在 display
从 true
变为 true
时销毁假的。
对于前一种情况,您可以使用 constructor(...)
、ngOnInit()
、ngAfterViewInit()
或 ngAfterContentInit()
、
以后ngOnDestroy()
可以用