简体   繁体   中英

angularjs override ng-init value by placeholder value

I have the following input:

<input type="text" placeholder="Enter your response" class="form-control" name="response" ng-model="test.response" ng-init="test.response='No Response'"/>

it is showing "no response" in the input text area, whereas I want to show the placeholder value. How can I override it? hide the ng-init value? thanks

Don't use ng-init.

If you want to pass 'No Response' instead of null then check condition on submit

for ex.

$scope.submitForm = function(){
  if(!test.response){
     test.response='No Response';
  }
}

The reason why it showing "No Response" it is because the value of the input is "No response". If you want to show the placeholder, remove the ng-init :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM