在下面的代码中,我正在调用的事实$(".test").buttonset();
正在破坏{{ item.value() }}
. 我认为这与 jQuery UI 重写 DOM 有关。
<html ng-app>
<head>
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/start/jquery-ui.css" type="text/css" rel="Stylesheet" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
<script type="text/javascript">
function ExampleCtrl($scope, $timeout) {
$scope.list = [
{ name: "a", value: 5 },
{ name: "b", value: 6 },
{ name: "c", value: 5 },
{ name: "d", value: 6 }
];
$scope.calc = [
[
{
name: "a, b avg",
value: function() { return(($scope.list[0].value + $scope.list[1].value) / 2) }
},
{
name: "c, d avg",
value: function() { return(($scope.list[2].value + $scope.list[3].value) / 2) }
}
]
];
$timeout(function() {
$(".test").buttonset();
}, 0);
}
</script>
</head>
<body ng-controller="ExampleCtrl">
<div class="test" ng-repeat="group in calc">
<div ng-repeat="item in group">
<input type="radio" name="a" id="{{item.name}}" />
<label for="{{item.name}}">{{item.name}}: {{ item.value() }}</label>
</div>
</div>
<ul ng-repeat="item in list">
<li>{{item.name}}: <input type="number" ng-model="item.value" />
</ul>
</body>
</html>
这是一个 jsFiddle 版本:http: //jsfiddle.net/vhLXW/