1

I'm new to Angular 6 and I've just managed to achieve calling API's into table rows

<tr *ngFor="let stats of stats$">
  {{ stats.StoragePercentage }}%
</tr>

This calls percentage figures into tables and I now want to add bootstrap progress bars alongside these figures to highlight this. I came across this Stack Overflow question: Change bootstrap progress-bar width from angularjs and tried the answers provided there with no luck. To me, what I have right now, that still doesn't work is the following:

<tr *ngFor="let stats of stats$">
  <div class="progress">
    <div class="progress-bar" 
      role="progressbar"
      ng-style="width: {{ stats.StoragePercentage }}"
      aria-valuenow="{{ stats.StoragePercentage }}"
      aria-valuemax="100">
        {{ stats.StoragePercentage }}%
    </div>
  </div>
</tr>

The errors I get are:

enter image description here

What am I doing wrong?

halfer
  • 19,824
  • 17
  • 99
  • 186
T.Doe
  • 1,969
  • 8
  • 27
  • 46

2 Answers2

1

One thing you are not doing correctly is using ng-style which is AngularJS directive and not for Angular 2+. Try the below:

<tr *ngFor="let stats of stats$">
  <div class="progress">
    <div class="progress-bar" 
      role="progressbar"
      [ngStyle]="{'width': stats.StoragePercentage + '%'}"
      aria-valuenow="{{ stats.StoragePercentage }}"
      aria-valuemax="100">
        {{ stats.StoragePercentage }}%
    </div>
  </div>
</tr>
codejockie
  • 9,020
  • 4
  • 40
  • 46
0

Like the error message says, the ng-style property is a isn't a know property.

Please see here

<tr *ngFor="let stats of stats$">
  <div class="progress">
    <div class="progress-bar" 
      role="progressbar"
      [ngStyle]="width: {{ stats.StoragePercentage }}"
      aria-valuenow="{{ stats.StoragePercentage }}"
      aria-valuemax="100">
        {{ stats.StoragePercentage }}%
    </div>
  </div>
</tr>
yougeen
  • 168
  • 1
  • 14
  • I get the error: Can't bind to 'ng-style' since it isn't a known property of 'div'. ("progress-bar" role="progressbar" [ERROR ->][ng-style]="width: {{stats.StoragePercentage}}" – T.Doe Jan 25 '19 at 13:20