Jonah Katz Jonah Katz - 1 year ago 88
AngularJS Question

Change value of input placeholder via model?

I'm trying to change the value of the input placeholder from a controller but cant quite figure out how.

input(type='text', ng-model='inputText', side='30', placeholder='enter username')

Is there a way to modify a model's element attributes?

Answer Source

You can bind with a variable in the controller:

<input type="text" ng-model="inputText" placeholder="{{somePlaceholder}}" />

In the controller:

$scope.somePlaceholder = 'abc';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download