下面是代码段,我遇到了错误 即使导入Formmodule之后,它也无法解析
import { BrowserModule } from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {AppComponent} from './app.component';
import{firstComponent} from './first/first.component';
import { SecondComponent } from './second/second.component';
@NgModule({
declarations: [
AppComponent,
firstComponent,
SecondComponent
],
imports: [
BrowserModule,
FormsModule
],
Sec.component.html
==================
<input type="text" [(ngmodel)]="TwoWayData" [value]="TwoWayData" name="" >
{{TwoWayData}}
TwoWayData:string='Fortune';
答案 0 :(得分:2)
您的问题在这里,在[[ngmodel)]中M是大写字母
[(ngmodel)]="TwoWayData"
替换
<input type="text" [(ngModel)]="TwoWayData" [value]="TwoWayData" name="">
{{TwoWayData}}