你怎麼這樣的事情設定的範圍值:如何訪問指令範圍中的ng-repeat項目?
<div ng-controller="MyCtrl">
<my-element ng-repeat="p in people" person='p'></my-element>
</div>
var myApp = angular.module('myApp',[]);
myApp.directive('myElement', function(){
return {
restrict: 'E',
template: '<div>{{ name }}</div> <div>{{ age }}</div>'
}
});
function MyCtrl($scope) {
$scope.people = [{ name: 'Mike', age: 20 },{name: 'Peter', age: 22 }];
}
是這種形式'ng-repeat =「p在人」人='p''仍然有效。我沒有看到它在文檔中提到,並給我錯誤。謝謝 – bsr
@bsr,它應該是有效的:[工作小提琴](http://jsfiddle.net/mrajcok/xgxQJ/) –
感謝馬克爲小提琴 – bsr