0
안녕하세요으로 다차원 인덱스 NG를 클릭합니다. 이 onclick 함수는이 요소의 모든 부모 색인을 포함하는 현재 색인을 필요로합니다 (예 : 아래 목록의 BMW의 경우 [0] [2] [1]).재귀 트리 템플릿 <p></p>이 재귀 적 구조를 보여줍니다 모든 상품에 온 클릭 기능을 가진 템플릿을 만들 수있는 방법인가, 매개 변수
A [0]
Tree [0][0]
...
House [0][1]
...
Car [0][2]
Mercedes [0][2][0]
BMW [0][2][1]
Audi [0][2][2]
VW [0][2][3]
Chrysler [0][2][4]
B [1]
...
C [2]
...
내 현재의 지침은 다음과 같이하지만 난 내가 NG 클릭 기능을위한 모든 요소의 FULL INDEX를 얻을 캔트 방법을 모른다.
컨트롤러의app.directive('collection', function() {
return {
restrict: "E",
replace: true,
scope: {
collection: '='
},
template: `
<ul>
<member ng-repeat='member in collection'
member='member' index='$parent.index + $index'>
</member>
</ul>`
}
});
app.directive('member', function ($compile) {
return {
restrict: "E",
replace: true,
template: "<li ng-click=\"select(member)\">{{member.title}}</li>",
link: function (scope, element, attrs) {
var collectionSt = '<collection collection="member.sub"></collection>';
if (angular.isArray(scope.member.sub)) {
$compile(collectionSt)(scope, function(cloned, scope) {
element.append(cloned);
});
}
}
}
});
'replace : true'를 사용하면 문제가 있는지 묻습니다. [AngularJS 지시어에서 '대체'속성이 사용되지 않는 이유는 무엇입니까?] (https://stackoverflow.com/questions/24194972/why-is-replace-deprecated-in-angularjs/35545445#35545445)를 참조하십시오. – georgeawg