I am unable to set a default value to ng-model="searchText". Here is the code I am using<input ng-model="searchText" value="can you see me" />
Can anyone help me with this?
I am unable to set a default value to ng-model="searchText". Here is the code I am using<input ng-model="searchText" value="can you see me" />
Can anyone help me with this?
Do not use ng-init on your input field to set the value. That's not required.
Just set the scope of your model to the value you would like. If it's simply placeholder text, it would be better to use the html5 placeholder attribute on your input element.
<input type="text" ng-model="someText" placeholder="Initial Text">
This will give you some text in the input field without the need to add anything to the controller scope.
If you want the text as a value you can pass without filling in the input field than you would need to set that in your controller.
$scope.someText = "Some Text";