Greetings! I currently have a custom directive that looks like this:
mainApp.directive('myMenu',function(){
return {
restrict : 'E',
scope :{menuItems : "=menuItems"},
compile: function(element, attributes) {
var linkFunction = function($scope, element, attributes){
for (i = 0;i<$scope.menuItems.length;i++){
element.append('<li><a href="#home">'+$scope.menuItems[i].name+'</a></li>');
}
}
return linkFunction;
}
}
});
I am implementing it in my HTML page as shown below:
<my-menu menuItems="menuItems"></my-menu>
However, when I check the console, I encounter an error message stating TypeError: Cannot read property 'length' of undefined