角度4-无法绑定到“ ngmodel”,因为它不是“ input”的已知属性。 (“

时间:2019-07-15 18:01:14

标签: angular

下面是代码段,我遇到了错误 即使导入Formmodule之后,它也无法解析

app.module.ts

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}}

Sec.component.ts

TwoWayData:string='Fortune';

1 个答案:

答案 0 :(得分:2)

您的问题在这里,在[[ngmodel)]中M是大写字母

[(ngmodel)]="TwoWayData"

替换

<input type="text" [(ngModel)]="TwoWayData" [value]="TwoWayData" name="">

{{TwoWayData}}