HTML佔位符不與NG-模型工作
隨着NG-模型 - 不工作
<input type="text" ng-model="Event.Sponsor.Amount" name="donationAmount" placeholder="{{PlaceHolderOther}}" required />
沒有NG-模型 - 工作
<input type="text" name="donationAmount" placeholder="{{PlaceHolderOther}}" required />
JS
$scope.PlaceHolderOther = "$50.00";
你能告訴我爲什麼placeholder
不與ng-model
工作?沒有ng-model
,工作正常。提前感謝。
出把(當它運行時)
<input type="text" name="donationAmount" placeholder="$50.00" ng-model="Event.Sponsor.Amount" required="" class="ng-pristine ng-valid ng-valid-required">
它顯示了placeholder
值properly.But不會顯示給user.Why?
更新:我已經找到了問題。那是texbox已經自動初始化。當我們刪除該值,然後它顯示佔位符值。所以如何避免這種情況下默認?
嘗試'$ scope.Event = {PlaceHolderOther: '$ 50.00'}'; – Vineet