gpt4 book ai didi

Angular 错误 : Can't bind to 'ngForFrom' since it isn't a known property of 'a'

转载 作者:太空狗 更新时间:2023-10-29 17:51:20 32 4
gpt4 key购买 nike

我相信这不是一个新错误。我已经尝试了解决错误的大部分方法,但我无法修复它。这是我的 appModule.ts 文件

import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { BrowserModule } from '@angular/platform-browser';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
CommonModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

看来我拥有所需的一切,如果缺少任何东西,请告诉我。在这里你可以看到我的模板,app.component.html

<div class="container">
<span class="text-center">
<h1>{{Portfolio.firstName+' '+Portfolio.middleName+' '+Portfolio.lastName[0]}}</h1>
<h2 class="subHeading">{{Portfolio.subheading}}</h2>
<img src="../assets/img/me.JPG" class="rounded-circle mx-auto d-block smallerImg">
</span>
<div class="row justify-content-center">
<a [href]="social.link" class="p-2" target="blank"
*ngFor="let social from Portfolio.socialMedia">
<i [style.color]="social.color" [class]="social.icon"></i>
</a>
</div>
</div>

这是我的 app.component.ts 文件

import { Component} from '@angular/core';
import { CommonModule} from '@angular/common';
import { OnInit, NgModule } from '@angular/core';
import { Portfolio } from './../models/portfolio.interface';
socialMedia: [
{
icon: 'fa fa-linkedin fa-2x',
link: 'https://www.linkedin.com/in/akshay-kumar-603740136/',
color: '#007bb6'
},
{
icon: 'fab fa-github',
link: 'https://github.com/akkie00',
color: '#6e5494'
}
],

在其中您可以看到我正在尝试循环的数组。这是我得到的错误:

    compiler.js:486 Uncaught Error: Template parse errors:
Can't bind to 'ngForFrom' since it isn't a known property of 'a'. ("v class="row justify-content-center">
<a [href]="social.link" class="p-2" target="blank"
[ERROR ->]*ngFor="let social from Portfolio.socialMedia">
<i [style.color]="social.color" [class]="soc"): ng:///AppModule/AppComponent.html@8:5
Property binding ngForFrom 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". ("
</span>

非常感谢任何帮助。

最佳答案

尝试

*ngFor="let social of Portfolio.socialMedia"

from 是错误的关键字。使用

关于 Angular 错误 : Can't bind to 'ngForFrom' since it isn't a known property of 'a' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50199502/

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