如何使用角度变量设置HTML属性?

时间:2014-12-15 13:44:35

标签: angularjs

  <div class="radio-inline" ng-repeat="customerOption in customerOptions">
       <input type="radio" name="customer" ng-change="getCustomers(customerType)" ng-model="customerType" ng-value="customerOption.Key" ng-checked="customerOption.Checked" />{{customerOption.Value}}
  </div>

这似乎没有做任何事情:

 ng-attr-id="{{customerOption.Value}}" 

或:

 ng-attr-id="customerOption.Value" 

或:

 id="customerOption.Value" 

这些完全放在html

1 个答案:

答案 0 :(得分:1)

这是一个显示使用ng-model作为默认广播的快速吸收者

http://plnkr.co/edit/F3M2fzLaYYrIwQdtuwHT?p=preview

app.controller('MainCtrl', function($scope) {
  $scope.gender = 'female';
});

<body ng-controller="MainCtrl">
  <input type="radio" name="sex" value="male" ng-model="gender">Male
  <br>
  <input type="radio" name="sex" value="female" ng-model="gender">Female
</body>