javascriptangularjsangularjs-ng-initng-init

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


Solution

  • 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';
      }
    }