0

现场演示

谁能解释为什么前两个按钮组有效,而第三个无效?

<div class="btn-group">
  <button ng-repeat="company in companies" 
          class="btn" 
          ng-model="radioModel.id" 
          btn-radio="company.id">
    {{company.name}}
  </button>
</div>

<div class="btn-group">
  <button class="btn btn-two" 
          ng-model="radioModel.id"
          btn-radio="2">
    two
  </button>
  <button class="btn btn-two" 
          ng-model="radioModel.id"
          btn-radio="3">
    three
  </button>
</div>

<div class="btn-group">
  <button ng-repeat="company in companies" 
          class="btn btn-{{ company.name }}" 
          ng-model="radioModel.id" 
          btn-radio="company.id">
    {{company.name}}
  </button>
</div>
$scope.companies = [ { id: 2, name: "two"}, {id: 3, name: "three"} ];
$scope.radioModel = { id: 3 };

此示例使用 AngularUI Bootstrap 0.5.0。如果我将其更改为 0.3.0,一切都会按预期进行。

4

1 回答 1

7

使用ng-class. 字符串插值class很时髦。

ng-class="'btn btn-' + company.name" 
于 2013-08-16T15:12:35.147 回答