Change value of input placeholder via model?

Jonah Katz picture Jonah Katz · Jul 18, 2013 · Viewed 131.8k times · Source

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

Wagner Francisco picture Wagner Francisco · Jul 18, 2013

You can bind with a variable in the controller:

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

In the controller:

$scope.somePlaceholder = 'abc';