[英]angularjs override ng-init value by placeholder value
我有以下輸入:
<input type="text" placeholder="Enter your response" class="form-control" name="response" ng-model="test.response" ng-init="test.response='No Response'"/>
它在輸入文本區域顯示“無響應”,而我想顯示占位符值。 我怎樣才能覆蓋它? 隱藏 ng-init 值? 謝謝
不要使用 ng-init。
如果您想傳遞“無響應”而不是 null,則在提交時檢查條件
例如。
$scope.submitForm = function(){
if(!test.response){
test.response='No Response';
}
}
之所以顯示“無響應”,是因為輸入的值為“無響應”。 如果要顯示占位符,請刪除 ng-init :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.