{
-
This sample can helps you to figure out how can get index or etc ... in directives.
var app = angular.module("app", []);
app.controller("controller", function ($scope) {
$scope.array1 = [
{id: "1-1"},
{id: "1-2"}
];
$scope.array2 = [
{id: "2-1"},
{id: "2-2"}
];
});
app.directive("exampleDirective", function () {
return {
restrict: "A",
scope: {
exampleDirective: "="
},
link: function (scope, element, attr, ngModel) {
console.log(scope.exampleDirective)
}
}
})
-
{{value.id}}
-
{{j.id}}
array1 index: {{$parent.$index}}
array2 index: {{$index}}
讨论(0)