Angular JS

Angular JS ng Placeholder Not Working

0
Angular JS

There are a few things you can try to solve the error “Angular JS ng Placeholder Not Working”:

Check for typos. Make sure that you are using the correct directive name, which is placeholder, not ngPlaceholder.

Make sure that you are using the placeholder attribute on the correct element. The placeholder attribute can only be used on input, select, and textarea elements.

Make sure that you have initialized the model that is bound to the input element. If the model is not initialized, then the placeholder will not be displayed.

Try clearing the form. If the form is already filled out, then the placeholder will not be displayed.

If you have checked all of the above and the placeholder is still not working, then you can try the following:

Use the data-placeholder attribute instead of the placeholder attribute. This is a workaround for a bug in AngularJS versions 1.3.x and earlier.

Use the ngInit directive to initialize the model. For example, the following code will initialize the name model to an empty string:

HTML
<input type=”text” ng-model=”name” ng-init=”name = ”” placeholder=”Enter your name”>

Use the ng-value directive to bind the value of the input element to the model. For example, the following code will bind the value of the name input element to the name model:

HTML
<input type=”text” ng-model=”name” ng-value=”name” placeholder=”Enter your name”>

If you are still having trouble, then you can post a question on Stack Overflow or the AngularJS Google Group.

Best WordPress Security Plugins

Previous article

How To Login into WordPress?

Next article

You may also like

Comments

Leave a reply

Your email address will not be published. Required fields are marked *

More in Angular JS