Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 841
ctrlz Avatar asked Apr 14 '26 16:04

ctrlz


1 Answers

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

like image 102
Pankaj Parkar Avatar answered Apr 16 '26 06:04

Pankaj Parkar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!