我有以下形式:角2 - ngForm.value沒有ngControl成員
import { Component } from '@angular/core'
@Component({
selector: 'form1',
template: `
<div >
<form (ngSubmit)="onSubmit(f)" #f="ngForm">
<input ngControl="email" type="text" id="mail" required>
<input ngControl="password" type="text" id="password" required>
<input ngControl="confirmPass" type="text" id="confirmPass" required>
<button type="submit">Submit </button>
</form>
</div> `
})
export class Form1Component{
onSubmit(form:any){
console.log(form.value);
}
}
問題是form.value
僅一個空的對象,並沒有ngControl
指令的值的符號。我錯過了什麼嗎?
你丟失了一些ngModel –
的可能的複製[Angular2窗體:驗證,ngControl,ngModel等](https://stackoverflow.com/questions/35383765/angular2-forms-validations-ngcontrol-ngmodel-etc) – jonrsharpe
這不是我的問題重複 – user2169286