入力が空であるかどうかを確認します。入力が空の場合にボタンを無効にします。
- 空でない場合は、[送信]ボタンを有効にします。
- 空の場合は、サブミット ボタンを無効にします。
(oninput)
と(onchange)
を試しましたが、実行されませんでした。
<input type="password" [(ngModel)]="myPassword" (oninput)="checkPasswordEmpty()"/>
checkPasswordEmpty() {
console.log("checkPasswordEmpty runs");
if (this.myPassword) {
// enable the button
}
}
はい、コンポーネント自体にコントロールを作成することができます;-) どういたしまして! –
新しいForms APIの使用(https://angular.io/docs/ts/latest/guide/forms.html) - ' –