我是角度新手,我遇到了这样的问题:
当我在元素中放入 ngIf 时,
<input type="text" *ngIf="true" id="name" name="name" class="form-control" required [(ngModel)]="name" #name="ngModel" />
aaaaaa {{name.dirty}}
Run Code Online (Sandbox Code Playgroud)
我有
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)
Run Code Online (Sandbox Code Playgroud)
但是,当我删除 ngIf 时,它工作正常。我可以知道原因以及解决此问题的任何迹象吗?
angular ×1