Angularjs2-双向绑定 Can't bind to 'ngModel' since it isn't a known property of 'input'.
双向绑定时
Can't bind to 'ngModel' since it isn't a known property of 'input'.
原因:app.module.ts中没有import HttpModule
注意:当在表单中使用[(ngModel)]
时,必须要定义name
属性。
<input type="text" class="form-control" id="name" required [(ngModel)]="model.name" name="name">