Angular'da yeniyim. Tour of Heroes'u öğrenmek için başlattım. Yani, bir bağlayıcı app.componentile yaratıldım two-way.
import { Component } from '@angular/core';
export class Hero {
id: number;
name: string;
}
@Component({
selector: 'app-root',
template: `
<h1>{{title}}</h1>
<h2>{{hero.name}} details!</h2>
<div><label>id: </label>{{hero.id}}</div>
<div><label>Name: </label>
<input [(ngModel)]="hero.name" placeholder="Name">
</div>
`,
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'Tour of Heroes';
hero: Hero = {
id: 1,
name: 'Windstorm'
};
}
Öğreticiyi takiben FormsModule'u içe aktardım ve açıklama dizisine ekledim. Bu adımda hata oluştu:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { FormsModule } from '@angular/forms';
@NgModule({
declarations: [
AppComponent,
FormsModule
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
İşte hata:
Yakalanmamış Hata: 'AppModule' modülü tarafından açıklanan beklenmeyen modül 'FormsModule'. Lütfen bir @ Boru / @ Direktifi / @ Bileşen ek açıklaması ekleyin.
importsvedeclarations