javascript - Angular UI Bootstrap progress bar - how to calculate "value" attribute with expression? - Stack O

I want to use UI bootstrap progressbar inside a table to give a visual representation of some statistic

I want to use UI bootstrap progressbar inside a table to give a visual representation of some statistics. The stats are percentages so it should work quite nicely, i.e. the higher the percentage the longer the bar.

I need to calculate the value with an expression, so I'm creating the progressbar element like so inside the table column:

<uib-progressbar type="info" value="{{ ((statValue / total) * 100) }}"></uib-progressbar>

Just to clarify, that's a simplified example, but the point is I cannot get any kind of expression to work when trying to calculate the value attribute.

It works if I give the attribute a different name and it works if I create a "value" attribute on any other type of element (e.g. a div). It just does not seem to work for the value attribute on the uib-progressbar element, which is exactly where I need it!

The error I get in the browser console is:

"Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{ ((statValue / total) * 100) }}] starting at [{ ((statValue / total) * 100) }}]."

I'm using angularjs 1.4.9 and angular-ui-bootstrap 1.1.2.

How do I get this to work?

I want to use UI bootstrap progressbar inside a table to give a visual representation of some statistics. The stats are percentages so it should work quite nicely, i.e. the higher the percentage the longer the bar.

I need to calculate the value with an expression, so I'm creating the progressbar element like so inside the table column:

<uib-progressbar type="info" value="{{ ((statValue / total) * 100) }}"></uib-progressbar>

Just to clarify, that's a simplified example, but the point is I cannot get any kind of expression to work when trying to calculate the value attribute.

It works if I give the attribute a different name and it works if I create a "value" attribute on any other type of element (e.g. a div). It just does not seem to work for the value attribute on the uib-progressbar element, which is exactly where I need it!

The error I get in the browser console is:

"Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{ ((statValue / total) * 100) }}] starting at [{ ((statValue / total) * 100) }}]."

I'm using angularjs 1.4.9 and angular-ui-bootstrap 1.1.2.

How do I get this to work?

Share Improve this question edited Aug 11, 2016 at 8:05 Pankaj Parkar 136k23 gold badges240 silver badges303 bronze badges asked Feb 14, 2016 at 9:13 ctrlzctrlz 951 silver badge9 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

value attribute should not be using interpolation {{}} inside value attribute, you could directly get scope variable values in it, like other directive of angular does ng-click, ng-if, etc.

<uib-progressbar type="info" value="((statValue / total) * 100)"></uib-progressbar>

Sample Here

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745302657a4621532.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信