Skip to content

Instantly share code, notes, and snippets.

@marufsiddiqui
Created June 24, 2013 05:36
Show Gist options
  • Select an option

  • Save marufsiddiqui/5847934 to your computer and use it in GitHub Desktop.

Select an option

Save marufsiddiqui/5847934 to your computer and use it in GitHub Desktop.
app.directive('collection', function () {
return {
restrict: "E",
replace: true,
scope: {
collection: '='
},
template: "<ul><member ng-repeat='member in collection' member='member'></member></ul>"
}
});
app.directive('member', function ($compile) {
return {
restrict: "E",
replace: true,
scope: {
member: '='
},
template: "<li></li>",
link: function (scope, element, attrs) {
if (angular.isArray(scope.member.children)) {
element.append("<collection collection='member.children'></collection>");
$compile(element.contents())(scope);
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment