gpt4 book ai didi

angular - 错误 Angular 13 : ngForOf not used by any directive. ..无法绑定(bind)到 'ngForOf'

转载 作者:行者123 更新时间:2023-12-02 18:24:22 25 4
gpt4 key购买 nike

我收到此错误

Property binding ngForOf not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". > 

Can't bind to 'ngForOf' since it isn't a known property of 'a'

我已经导入了所有必需的模块:CommonModuleBrowserModuleReactiveFormsModule

app.module.ts:

import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { RecipesComponent } from './components/recipes/recipes.component';
import { RecipeListComponent } from './components/recipes/recipe-list/recipe-list.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';

@NgModule({
declarations: [
AppComponent,
HeaderComponent,
RecipesComponent,
RecipeListComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule,
CommonModule,
],
providers: [],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule { }

食谱列表.component.ts:

<div class="row">
<div class="col-xs-12">
<a href="#" class="list-group-item clearfix" *ngFor="let recipe of recipes"> // error ngFor
<div class="pull-left">
<h4 class="list-group-item-heading"> {{ recipe.name}} </h4>
</div>
<span class="pull-right">
<img [src]="recipe.imagePath" alt=" {{recipe.name}} " srcset="" class="img-responsive" style="max-height: 50px">
</span>
</a>
<app-recipe-item></app-recipe-item>
</div>
</div>

我正在使用 Angular v13.1.1/Node v16.13.1/VSCode v1.63.2

screen of my error

最佳答案

禁用 Visual Studio 扩展“Angular Language Service”解决了该问题。

关于angular - 错误 Angular 13 : ngForOf not used by any directive. ..无法绑定(bind)到 'ngForOf',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70425548/

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