Diego Unanue
Diego Unanue

Reputation: 6826

Angular UI mask empty placeholder

I am using angular ui mask directive for a date field and its adding underscores for the placeholder. Is there a way to show nothing on the placeholder?

Upvotes: 3

Views: 5594

Answers (4)

Mansi  Teharia
Mansi Teharia

Reputation: 1077

Please try this once.

<div ng-app="myApp">
  <input class="form-control" type="text" ng-model="accountNumber" ui-mask="9999 9999 9999 9999 999"  ui-mask-placeholder-char="space" />
</div>

Using ui-mask-placeholder-char="space" , you can get empty placeholder.

Upvotes: 3

Wicked Shani
Wicked Shani

Reputation: 11

It would be better if we prefer what the Library is providing. So, I would suggest you to use

ui-mask-placeholder-char="space"

add this to your HTML and it will work just fine.

Upvotes: 1

Diego Unanue
Diego Unanue

Reputation: 6826

Regarding that is a plugin issue I found this amazing library called ngMask:

https://github.com/candreoliveira/ngMask

Upvotes: 3

Stone
Stone

Reputation: 2668

This is a long standing bug (in my opinion) in the plugin. There's an outstanding PR that fixes the issue but I believe it's not being approved because the author didn't fix the tests: https://github.com/angular-ui/ui-utils/issues/181

I have broken the changes out into a custom version. Include as a directive in your project instead of using Bower to include the official version. Credit goes to: https://github.com/qwyzyx for the code updates. I've just taken the time to convert it over to coffeescript and document the changes.

You'll still have to include the 'ui.mask' module in your app just like the normal version on Github. Config as normal if desired.

https://gist.github.com/lstone/a952e169090dc3c64594

If you need to convert to JS: http://js2.coffee/

Upvotes: 1

Related Questions