我有這個輸入:如何驗證並顯示錯誤消息 - Angular2 Material Design?
<form #f="ngForm" name="productForm">
<md-input [(ngModel)]="product.price" name="price" required="true" placeholder="Price (USD)"></md-input>
<div ng-messages="productForm.price.$error" role="alert">
<div ng-message-exp="['required']">
Price is required
</div>
</div>
</form>
但該消息的價格要求不出來。
我應該如何正確格式化錯誤信息?
當價格輸入爲空,出現NG-無效類:
我要的是有一個看起來像這樣的類似angular1 md design風格:
對不起,你是什麼意思,!email.errors?.email? – Vicheanak
關於這一個的討論在官方材料2回購https://github.com/angular/material2/issues/348 – Kuncevic
您可能想要編輯最新版本的答案。 dividerColor現在需要成爲md-input-container的一部分而不是md-input – cport1