检查组件/指令的“销毁者”

问题描述

我有以下情况:指令检测到ElementRef发生的更改,并在销毁它时执行操作:

模板:

<input doSomethingOnDestory *ngIf="showMyInput" type="text" [(ngModel)]="myInput">

指令:

@Directive({
selector: '[ngModel][doSomethingOnDestory]'
})
export class DoSomethingOnDestory Directive implements OnDestroy {
    @Output() ngModelChange: EventEmitter<any> = new EventEmitter();

    constructor(){}

    ngOnDestroy() {
        //Do something to the model
    }
}

现在,我进入一种情况,仅在组件自身被破坏(例如,//Do something to the model虚假)时才运行showMyInput而不是通过“外部驱逐舰”(例如,表单的整个包装组件都被摧毁)

我该怎么做?

谢谢:-)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...