I'm currently writing an application in AngularJS, and I've stumbled across a problem while using ng-model with input fields.
In the case that a user does not enter any text in one input field, is there any way to bind a default value to the ng-model? A sample of the code is shown below:
<input class="formInput" placeholder="{{ testVar.hasName.name }}" type="text" id="nameUpdate" ng-model="upd.name">
The idea is a user will be updating data. The placeholder will show the existing data, in this case the name, and updating this field will bind to the model. However, if a user does not wish to update this particular field, how can I bind the existing value to the model? I've noticed giving the input a value="xyz" prevents the ng-model from working properly.
I should note defining this information in the controller as a default is not an acceptable solution, as the data within testVar will vary.
Thanks in advance for any help.