AngularJS: ng-placeholder not working

In HTML:

<input type="text" placeholder="{{doctorname ? doctorname : 'Dr. your name'}}"
       class="editable-class" ng-model="doctor.name" readonly/>

In controller:

$scope.doctorname = $scope.doctorinfo.name;

I don't think there's any ngPlaceholder directive. Try changing your code to:

<input type="text" class="form-control" id="Username" name="Username" data-ng-model="user.Username" required="" placeholder="{{user.AdAccount ? 'Username' : 'Ad Login'}}" />

That is, change ng-placeholderinto just placeholder, and everything should work fine.

(Note also the self-closing slash if you need to conform to valid XHTML.)


You can try this:

<input type="text" class="form-control" id="Username" name="Username" data-ng-model="user.Username" required="" ng-attr-placeholder="{{user.AdAccount ? 'Username' : 'Ad Login'}}">

ng-attr- will work with any HTML attribute.