Angular UI mask empty placeholder

旧街凉风 提交于 2019-12-12 12:58:32

问题


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?


回答1:


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

https://github.com/candreoliveira/ngMask




回答2:


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.




回答3:


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/




回答4:


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.



来源:https://stackoverflow.com/questions/32973660/angular-ui-mask-empty-placeholder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!