角度错误:无法绑定到“ngForFrom”,因为它不是“a”的已知属性

Aks*_*mar 8 typescript angular

我相信这不是一个新错误。我已经尝试了解决错误的大部分方法,但我无法修复它。这是我的 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 { }
Run Code Online (Sandbox Code Playgroud)

看起来我拥有所需的一切,如果缺少任何东西,请告诉我。在这里你可以看到我的模板 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>  
Run Code Online (Sandbox Code Playgroud)

这是我的 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'
    }
  ],
Run Code Online (Sandbox Code Playgroud)

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

    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>
Run Code Online (Sandbox Code Playgroud)

任何帮助深表感谢。

Sha*_*vek 8

尝试

*ngFor="let social of Portfolio.socialMedia"
Run Code Online (Sandbox Code Playgroud)

from是错误的关键字。用of