Soy más nuevo en Angular 2 Escribí el código para mostrar la lista de películas, pero muestra un error. Verifique mi código ...
debajo está mi código
component.ts: file
import { Component} from "@angular/core";
@Component({
selector:"my-app",
template:`<h1>welcome to my shop</h1>
<p>we have the following movies available</p>
<div>
<p *ngfor=#movie of movieList>{{movie}}</p>
</div>`
})
export class MyShopComponent{
public movieList=["batman vs superman","civil war","deadpool"]
}
app.module.ts: archivo
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { MyShopComponent } from "./app.component";
@NgModule({
imports: [
BrowserModule,
FormsModule
],
declarations: [
MyShopComponent
],
bootstrap: [ MyShopComponent ]
})
export class AppModule { }
Respuestas
5 para la respuesta № 1Plantilla de componente interior ngFor
debería usar let
Para definir la variable iterable actual. También corrija el error tipográfico de *ngfor
a *ngFor
con atributo de envoltura por "
<p *ngFor="let movie of movieList">{{movie}}</p>