Angular 角度和离子-为什么该指令不记录离子输入的变化?
我正在尝试使用ion input,但有两个问题我不知道如何解决: 1-显示ion输入时无法加载掩码-问题是输入元素只在一段时间后出现在nativeElement的子节点上,因此我没有找到要实现的挂钩。为了解决这个问题,我在setTimeout中添加了一些代码,这样我可以找到包装的输入:Angular 角度和离子-为什么该指令不记录离子输入的变化?,angular,typescript,ionic-framework,angular2-directives,ionic3,Angular,Typescript,Ionic Framework,Angular2 Directives,Ionic3,我正在尝试使用ion input,但有两个问题我不知道如何解决: 1-显示ion输入时无法加载掩码-问题是输入元素只在一段时间后出现在nativeElement的子节点上,因此我没有找到要实现的挂钩。为了解决这个问题,我在setTimeout中添加了一些代码,这样我可以找到包装的输入: public ngOnInit():void { setTimeout(()=>{ this._element=this.findElement(); resolve
public ngOnInit():void {
setTimeout(()=>{
this._element=this.findElement();
resolvedPromise.then(() => this._applyValueChanges());
},1000);
}
findElement():any{
if (this._elementRef.nativeElement.tagName === 'INPUT') {
return this._elementRef.nativeElement
} else {
let index;
for(index=0;index<this._elementRef.nativeElement.childNodes.length;index++)
if (this._elementRef.nativeElement.childNodes[index].tagName === 'INPUT')
return this._elementRef.nativeElement.childNodes[index];
}
}
所以,我想知道:如何使registerOnChange与ion输入元素一起工作?有没有一种方法可以不使用setTimeout在onInit中找到包装的输入
public registerOnChange(fn:any):void {
this._onChange = fn;
return;
}