0
我不明白爲什麼我得到這個錯誤與Angular 4,我甚至從angular/common導入ngFor。我發現的問題都與angular 1 => angular 2有關。而且我相信瀏覽器模塊導入了通用庫。這與我以前構建的角度2應用程序的配置相同。 錯誤:Angular 4 ngFor
無法綁定到'ngForIn',因爲它不是'div'的已知屬性。 (「] * ngFor = '讓resumeEntries條目'>
元器件
import { Component, OnInit } from '@angular/core';
import {RetrieveService} from '../../services/retrieve.service';
@Component({
selector: 'app-resume',
templateUrl: './resume.component.html',
styleUrls: ['./resume.component.css']
})
export class ResumeComponent implements OnInit {
resumeEntries:any[];
constructor(private retrieveService:RetrieveService) { }
ngOnInit() {
this.retrieveService.getResume().subscribe(response=>{
this.resumeEntries=response.entries;
});
}
}
HTML
<div *ngFor='let entry in resumeEntries'>
works
</div>
App.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {RouterModule,Routes} from '@angular/router';
import { HttpModule } from '@angular/http';
//components
...
//services
import {RetrieveService} from './services/retrieve.service';
const AppRoutes: Routes =[
{path:'resume',component:ResumeComponent},
{path:'admin', component:AdminComponent},
{path:'',component:LandingPageComponent}
]
@NgModule({
declarations: [
AppComponent,
LandingPageComponent,
DashBarComponent,
ResumeComponent,
SocialMediaComponent,
AdminComponent,
AdminContactInfoComponent
],
imports: [
BrowserModule,
RouterModule.forRoot(AppRoutes),
HttpModule
],
providers: [RetrieveService],
bootstrap: [AppComponent]
})
哦,我看到他們改變了它作爲V4.0.0的,這工作,謝謝。 –