<form #f="ngForm" (ngSubmit)="onFormSubmit(f.value)">
<label>Name:</label><input type="text" ngControl="name" #name="ngForm" required />
<br />
<div [hidden]="name.valid" [style.color]="'red'">Invalid name input</div>
<label>Email:</label><input type="text" ngControl="email" #email="ngForm" />
<br />
<div [hidden]="email.valid " [style.color]="'red'">Invalid email input</div>
<button type="submit" [disabled]="!f.valid">Submit</button>
</form><input [ngModel]="todo.text" (ngModelChange)="todo.text=$event"></input><input [(ngModel)]="todo.text"></input><form (ng-submit)="onSubmit()" #f="form">
<input ng-control="name" [(ng-model)]="name">
<button>Click me and check console</button>
</form>@Directive({
selector: '[ngModel]',
host: {
"[value]": 'ngModel',
"(input)": "ngModelChange.next($event.target.value)"
}
})
class NgModelDirective {
@Input() ngModel:any; // stored value
@Output() ngModelChange:EventEmitter; = new EventEmitter() // an event emitter
}