The progress bar works in all browsers except IE (Angular + bootstrap)

I use Angular and bootstrap to show a progress bar. here is the html

<div class="progress progress-striped active "> <div class="bar bar-info" style="width:{{score}}%"></div> </div> 

score comes from my controller. This code works in all browsers except IE.

Any help would be appreciated.

+4
source share
3 answers

Just go to the following:

 <div class="progress progress-striped active "> <div class="bar bar-info" ng-attr-style="width:{{score}}%;"></div> </div> 

If you want to use Angular interpolation in an HTML attribute such as a style, you need to use the ng-attr- for this attribute so that it can be ng-attr- in the browser.

+9
source

If your β€œscore” gets the value correctly, apply the style a little differently, the code below worked for me:

Change your style attribute to ng-style = "width = {width: '{{score}}%'}"

 <div class="progress progress-striped active "> <div class="bar bar-info" ng-style="width={width:'{{ score}}%'}"></div> </div> 
+7
source

Detected workaround from theDemi post . You should write your own directive as follows:

 angular.module('myApp').directive('myProgress', function() { return function(scope, element, attrs) { scope.$watch(attrs.myProgress, function(val) { element.html('<div class="bar" style="width: ' + val + '%"></div>'); }); } }); 

using:

  <div class="progress" my-progress="nameOfYourProgressModelVariable"></div> 
+5
source

Source: https://habr.com/ru/post/1487652/


All Articles