angularjsng-bindangularjs-ng-value

Default value of input textbox in AngularJS


How do I set the default value of an input textbox in AngularJS so that it can be altered later? I wish to be able to submit the changed value of the textbox(using ng-model) to the server. Would using ng-value to set the initial value of the textbox be the correct approach in this case?


Solution

  • Set the ngModel value:

    <input type="text" ng-model="myInput" />
    
    $scope.myInput = "Default";