我是新手,遇到了这样的问题:
当我在元素中放入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] 删除。
我来说两句