角度4错误TypeError:无法读取未定义的属性“脏”

托尼

我是新手,遇到了这样的问题:

当我在元素中放入ngIf时,

 <input type="text" *ngIf="true" id="name" name="name" class="form-control" required [(ngModel)]="name" #name="ngModel" />
aaaaaa {{name.dirty}}

我有

ERROR TypeError: Cannot read property 'dirty' of undefined
at Object.eval [as updateRenderer] (PrepareInvestmentComponent.html:1)
at Object.debugUpdateRenderer [as updateRenderer] (core.es5.js:13105)
at checkAndUpdateView (core.es5.js:12256)
at callViewAction (core.es5.js:12599)
at execComponentViewsAction (core.es5.js:12531)
at checkAndUpdateView (core.es5.js:12257)
at callViewAction (core.es5.js:12599)
at execEmbeddedViewsAction (core.es5.js:12557)
at checkAndUpdateView (core.es5.js:12252)
at callViewAction (core.es5.js:12599)

但是,当我删除ngIf时,它可以正常工作。我可以知道为什么以及任何解决此问题的迹象吗?

埃尔默丹塔斯

似乎角度不允许您使用参考变量+ *ngIf...解决方案是使用ng-container或仅使用div

像这样:https : //stackblitz.com/edit/angular-48763586-rsrtsa?file=app/app.component.html

有一个似乎与您的情况有关的问题尚未解决:https : //github.com/angular/angular/issues/13974

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TypeError中的错误:无法读取未定义的属性“标志”

TypeError:无法读取未定义角度的属性“ childNodes”

TypeError:无法读取未定义角度2的属性“ http”

错误TypeError:无法读取未定义的属性'length'

角度4无法读取未定义的属性“ id”

错误TypeError:无法读取未定义角度4的属性“无效”

角度生成错误:TypeError:无法读取未定义的属性“ line”

角度:错误类型错误:无法读取未定义的属性___

TypeError无法读取未定义的属性“ length”-角度4

错误TypeError:无法读取角度高图表中未定义的属性“ 0”

无法读取未定义角度4的属性“名称”

角度6:错误TypeError:无法读取未定义的属性“ toLowerCase”

角度组件测试错误:TypeError无法读取未定义的属性“ subscribe”

错误TypeError:无法读取角度4中未定义的属性'createComponent'

TypeError:无法读取未定义角度的属性“发射”

错误TypeError:无法读取未定义的属性“打开”

错误TypeError:无法读取未定义的属性“值”:角度6

作为错误:TypeError:无法读取未定义的属性“位置”

错误TypeError:无法读取角度未定义的属性'closeRow'

角度-错误TypeError:无法读取未定义的属性'title'

错误TypeError:无法读取未定义的属性“匹配”

错误TypeError:无法读取POST HTTP调用上未定义的属性“ subscribe”-角度[8]

错误TypeError:无法读取未定义的属性“调用”

TypeError:无法读取未定义的属性'requestContent'。HMR。角度的

角度错误TypeError:无法设置未定义的属性“名称”

角度测试-TypeError:无法读取未定义的属性“ 7”

角度 4 绑定图像无法读取未定义的属性

反应 - 错误:TypeError:无法读取未定义的属性(读取“then”)

“TypeError:无法读取未定义的属性(读取'hasOwnProperty')”错误