加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

将ReactiveFormsModule添加到我的angular 4应用程序后,没有获得N

发布时间:2020-12-17 06:52:16 所属栏目:安全 来源:网络整理
导读:我收到此错误 – “模板解析错误: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 currenci
我收到此错误 – “模板解析错误: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>

还要确保在导入下的app.module.ts中导入FormsModule
从’@ angular / forms’导入{FormsModule,ReactiveFormsModule};

@NgModule({
    imports: [
         FormsModule      
    ]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读