angular
2017-03-18 73 views 0 likes 
0

我有這個輸入:如何從空輸入(ngModel)值?

<input id="password" type="password" class="form-control" name="password" [(ngModel)]="password"> 

現在我有功能提交在哪裏,如果用戶如果不,我已經在別的此輸入有效密碼檢查:

else{ 
     this.error = true; 
     this.message = 'Wrong username or email!' 
    } 

而且我怎樣才能在別人添加像這樣清空該字段:

this.password = ''; 
+0

問題是什麼? 'this.password ='''不工作? –

+0

我得到 – uzhas

+1

你需要聲明它在你的component..https錯誤房產密碼不對類型LoginComponent存在://angular.io/docs/ts/latest/guide/template-syntax.html# #ngModel –

回答

1

您需要在組件中聲明密碼。

password: string; 
+0

這就是它tnx :) – uzhas

相關問題