幽梦林子 发表于 2017-7-15 19:57:31

Angularjs4.0如何进行双向数据绑定

本帖最后由 幽梦林子 于 2017-7-15 19:58 编辑

Angularjs4.0如何进行双向数据绑定呢?具体方法如下:
<input[(ngModel)]="inputValue">

注意引入:FormsModule

import { FormsModule } from '@angular/forms';


@NgModule({
declarations: [
    AppComponent,
    HeaderComponent,
    FooterComponent,
    NewsComponent
],
imports: [
    BrowserModule,
    FormsModule
],
providers: [],
bootstrap:
})
export class AppModule { }


使用:

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

{{inputValue}}

页: [1]
查看完整版本: Angularjs4.0如何进行双向数据绑定