Hi, I have the following problem:
In my opinion, I call the prepareDynamicData (itemMenu) function;
<div ng-repeat="itemMenu in menuDetailsData.categories" class="headDetails fontH2"> <div style="display: none">{{prepareDynamicData(itemMenu)}}</div> <a href="#" ng-show="dynamicData.expand">{{itemMenu.name}}</a> <div ng-repeat="cat in dynamicData.data"> <p>{{cat.name}}</p> <div class="articles"> <div ng-repeat="art in cat.items" class="article"> <div class="price"> <div></div> <span><i>βͺ</i>{{art.price}}</span> </div> <div class="artDescr"> <span class="fontTitle">{{art.title}}</span> <p class="fontDetails">{{art.description}}</p> </div> </div> </div> </div> </div>
I know that the top loop repeats only 2 times (this is verified), but the prepareDynamicData (itemMenu) function calls 4 times, I donβt know why !? Here is my controller:
function MenuItemCtrl($scope, $routeParams, $http, $location, sharedData) { if (sharedData.getMenuDetails() == null) { $location.path('/menu'); return; } else { $scope.menu = sharedData.getMenu(); $scope.menuDetailsData = sharedData.getMenuDetailsData($routeParams.itemId); } $scope.dynamicData = { data : new Array(), expand : false }; $scope.prepareDynamicData = function (itemMenu) { if (itemMenu.items != null) { $scope.dynamicData.data[0] = itemMenu; $scope.dynamicData.expand = false; } else { $scope.dynamicData.data = itemMenu.categories; $scope.dynamicData.expand = true; } }
}
Can you help me explain why this is happening! thanks
source share