2
상위 지시문의 ng-repeat 반복자 색인을 인쇄하고 싶습니다. 의사 코드 :내부 ng-transclude의 AngularJS 상위 지시문 범위
index.html을
<div data-repeatable>
{{$index}} does not display
</div>
template.html
<div ng-repeat="i in getTimes(5) track by $index">
{{$index}} displays correctly
<div ng-transclude></div>
</div>
는
// Other code omitted
.directive('repeatable', function() {
return {
scope: {},
transclude: true,
templateUrl: 'template.html'
};
})
나는 전자를했습니다 app.js 다양한 접근법/개조가 있었지만 지금까지는 아무 것도 작동하지 않았습니다. 어떤 도움이라도 대단히 감사하겠습니다!
감사합니다.
부모에서 자식으로 스코프를 전달하고 디렉티브 컨트롤러에서 '$ scope.index ='number''를 업데이트하지 않으면 거기에 있는지 여부를 확인합니다. 부모에서 자동 업데이트됩니다 –