如何申请一个API人物来引导进度条角6?

问题描述 投票:1回答:2

我是新来的角6,我刚刚成功地实现调用API的成表中的行

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

这就要求百分比数字到表,现在我想添加的引导进度条沿着这些数字来强调这一点。我碰到这个堆栈溢出问题:Change bootstrap progress-bar width from angularjs和尝试,没有运气只要答案。对我来说,我现在所拥有的,仍然不能正常工作如下:

<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>

我得到的错误是:

enter image description here

我究竟做错了什么?

angular6 progress-bar angular-ui-bootstrap
2个回答
1
投票

你是不是在做正确的一件事是使用ng-style这是AngularJS指令,而不是角2+。试试下面的:

<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>

0
投票

像错误消息称,NG-style属性是不是知道属性。

请参阅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>
© www.soinside.com 2019 - 2024. All rights reserved.