作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我相信这不是一个新错误。我已经尝试了解决错误的大部分方法,但我无法修复它。这是我的 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/
我相信这不是一个新错误。我已经尝试了解决错误的大部分方法,但我无法修复它。这是我的 appModule.ts 文件 import { CommonModule } from '@angular/com
我是一名优秀的程序员,十分优秀!