당신은 어떻게 이런 일에 대한 범위 값을 설정 않습니다지시어 범위에서 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 }];
}
이 사람 "사람 = 'p' '의 유효한'ng-repeat ="p 형식입니다. 나는 문서에 언급 된 것을 보지 못하고 나를 위해 오류를 준다. 감사합니다 – bsr
@bsr, 유효해야합니다 : [작동 fiddle] (http://jsfiddle.net/mrajcok/xgxQJ/) –
피들에 대 한 감사 마크 – bsr