I'm trying to make a recursive menu with angularJS, but I keep getting the error: Maximum call stack size
My directives:
angular.module("application").directive("navigation", [function () { return { restrict : 'E', replace : true, scope : { menu : '=' }, template : '<ul><navigation-item ng-repeat="item in menu" submenu="item"></navigation-item></ul>', link : function ($scope, elem, attrs) {} } } ]); angular.module("application").directive("navigationItem", [function () { return { restrict : 'E', replace : true, scope : { submenu : '=' }, template : '<li>{{ submenu }}<navigation menu="submenu.Children"></navigation></li>', link : function ($scope, elem, attrs) {} } } ]);
My controller:
app.controller('myController', ['$scope', function (ng) { ng.menu = [{ Id : 1, Nome : "Contact", Children : [{ Nome : "Testing", Children : [] }] }]; } ]);
Here is how I use it:
<navigation menu="menu"></navigation>
http://jsfiddle.net/7sq3n/
source share