angular 双向数据绑定

第一步 引入FromsModule

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    AppRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
<div style="text-align:center">
  <h1>
    Welcome to {{ title }}!
  </h1>

  <input type="text" [(ngModel)]="inputValue"/> 
  <h1>
    {{ inputValue }}
  </h1>


</div>

 效果图:

posted on 2019-05-20 16:04  LoaderMan  阅读(1397)  评论(0编辑  收藏  举报

导航