条件基于

时间:2015-08-06 10:18:40

标签: angularjs angularjs-directive

如果pro_percent的值小于75,我想显示“Complete it”。

    <progressbar class="progress-striped active" max="100" value="user.pro_percent" type="success">
            {{user.pro_percent | number:0 }}
    </progressbar>
    <span ng-show="user.pro_percent < 75">Complete it</span>

我无法理解ng-show的条件。我该怎么去这里?

编辑:

我按照建议添加了此功能,并获得了以下结果。

    <div class="progress-striped active progress ng-isolate-scope" max="100" value="user.pro_percent" type="success">
      <div class="progress-bar progress-bar-success" ng-class="type &amp;&amp; 'progress-bar-' + type" role="progressbar" aria-valuenow="73.33" aria-valuemin="0" aria-valuemax="100" ng-style="{width: (percent < 100 ? percent : 100) + '%'}" aria-valuetext="73%" ng-transclude="" style="width: 73.33%;">
        <span class="ng-binding ng-scope">
            73%
        </span>
      </div>
    </div>
    <small ng-show="user.pro_percent < 75" class="ng-hide">Complete it</small>

2 个答案:

答案 0 :(得分:1)

我认为这应该可以正常工作

<span ng-show="user.pro_percent < 75">Complete it</span>

答案 1 :(得分:1)

如果user.pro_percent是一个数字,那么应该这样做:

<span ng-show="user.pro_percent < 75">Complete it</span>