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?
Default value of input textbox in AngularJS
Asked Answered
Set the ngModel
value:
<input type="text" ng-model="myInput" />
$scope.myInput = "Default";
Thanks for the prompt reply :). I had thought of that, but would I be able to access the updated value of that field using $scope.myInput when I wish to submit data to the server –
Doreendorelia
@NipunParasrampuria -- Yeah,
$scope.myInput
will reflect whatever you put in that input
–
Moonstruck © 2022 - 2024 — McMap. All rights reserved.
ng-init
directive simply – Hark