首页 > 解决方案 > TS2339:“AbstractControl”类型上不存在属性“控件”

问题描述

我正忙于 Udemy 上的“Angular - 完整指南(2021 版)”,但遇到了一些问题:

我不断收到以下错误:TS2339:“AbstractControl”类型上不存在属性“控件”我正在使用最新版本的 Angular。

这是我的 HTML 代码:

                    <div class="row" *ngFor="let ingredient of recipeForm.get('ingredients').controls; let i = index"
                        [formGroupName]="i" style="margin-top: 10px;">
                        <div class="col-xs-8">

任何建议将不胜感激!谢谢!

标签: angularcontrols

解决方案


      <div
        class="row"
        *ngFor="let ingredientCtrl of recipeForm.get('ingredients')['controls']; let i = index"
        [formGroupName]="i"
        style="margin-top: 10px;">

// 只需使用 ['Controls'] 而不是 .Controls


推荐阅读