AngularJS: Should I use a filter to convert integer values into percentages?

后端 未结 2 2028
谎友^
谎友^ 2021-02-20 02:20

I need to collect a rate of change - in percentages - from my application\'s users. Here is the text input I am using:

相关标签:
2条回答
  • 2021-02-20 03:00

    Well, you just did it the absolute right way with the ctrl.$parser and ctrl.$formatter You just can leave out the $filter thing, its absulotuly not needed there. Just check it out they don't use the filter there, too.

    0 讨论(0)
  • 2021-02-20 03:09

    I think you should use a directive. If you think you are about to fall back to using JQuery to start manipulating the DOM elements then a directive is probably what you want.

    This is an example of a filter: http://embed.plnkr.co/TT6ZwOF6nYXwMcemR3JF/preview

    What you could do is filter the value you enter as part of a watch event. However that depends on your specific use case.

    0 讨论(0)
提交回复
热议问题