angular 5升级到6之后
我尝试更新我的表单:
anguar 5 我有:
<select [ngModel]="toto" (ngModelChange)="onChange($event)"
<option *ngFor="let toto of totos" [ngValue]="toto.id">{{toto.libelle}}</option>
</select>
angular 6 我更新了:
<select #oldValue="ngModel" [(ngModel)]="toto" (ngModelChange)="onChange(oldValue)"
<option *ngFor="let toto of totos" [ngValue]="toto.id">{{toto.libelle}}</option>
</select>
我得到了这个错误:
compiler.js:215 Uncaught Error: Template parse errors:
There is no directive with "exportAs" set to "ngModel" ("
我的 app.component.ts 中有 FormsModule
我忘记了什么?谢谢你
最佳答案
在你的组件中是否有一个名为“toto”的变量名,如果它存在......好的
一个是您需要正确关闭打开的选择标签。
当您使用 [(ngModel)] 时,您需要在 forrm 元素中设置名称
关于angular - 形式 Angular 6 的 ngModelChange,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50488083/