gpt4 book ai didi

angular - 将 ReactiveFormsModule 添加到我的 Angular 4 应用程序后,没有获得 NgControl 错误的提供者

转载 作者:太空狗 更新时间:2023-10-29 17:04:42 28 4
gpt4 key购买 nike

我收到此错误 - “模板解析错误:NgControl 没有提供者”

 The error comes from this line of code

--> <select (ngModel)="currencies" (ngModelChange)="showPurchase($event)" class="annka-center" name="curencies">
<option *ngFor="let money of currencies; let i = index" (ngValue)="money" (click)="showPurchase(money)"> {{money.Currency}} </option>
</select>

在我将 ReactiveFormsModule 添加到我的应用程序之前,上面的代码运行得很顺利。

我在这里尝试了解决方案

ERROR in : No provider for NgControl Angular AOT

但这对我不起作用。我正在使用 Angular 4。

最佳答案

应该是

<select [(ngModel)]="currencies" (ngModelChange)="showPurchase($event)" class="annka-center" name="curencies">
<option *ngFor="let money of currencies; let i = index" (ngValue)="money" (click)="showPurchase(money)"> {{money.Currency}} </option>
</select>

还要确保在 imports 下的 app.module.ts 中导入 FormsModule

import { FormsModule, ReactiveFormsModule } from '@angular/forms';

@NgModule({
imports: [
FormsModule
ReactiveFormsModule
]

关于angular - 将 ReactiveFormsModule 添加到我的 Angular 4 应用程序后,没有获得 NgControl 错误的提供者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48525216/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com