AngularJS - "10 $digest() iterations reached" when ng-view ng-repeat dependant on $routeParams -
i new angular , first time dealing routing, please excuse me if questions bit confusing. actual logic , structure app more complex , using several services, general idea of part having issues with. appreciate help! thanks.
solved
i adding same template recursively. inside template, changed ng-repeat template 1 , worked perfectly. http://jsfiddle.net/georgiangelov/9yn3z/111/
updated jsfiddle: http://jsfiddle.net/georgiangelov/9yn3z/106/
i updated fiddle chandermani ( removed controllers , left 1 copy of it) "10 $digest() iterations reached" whenever click on add root button or whenver click on section keeps giving me error... no idea why.
so have app have menu on left side can add more elements called sections menu. menu section item derived array called sections sits in controller , when add section adds array named sections.
$scope.sectionid = $routeparams.sectionid; $scope.sections = []; $scope.counter = 1; $scope.section = {}; $scope.addsection = function(){ $scope.sections.push({ id: $scope.counter++, name: 'random name', roots: [] }); }; *html sections *
<body ng-app="myapp" ng-controller="mycontroller"> <div class="tabbable tabs-left pull-left"> <ul class="nav nav-tabs"> <li ng-repeat="section in sections" ng-click="setsectionselected(section)" ng-class="{active : issectionselected(section)}"><a href="#/section/{{section.id}}" data-toggle="tab">{{section.name}}</a></li> </ul> <button class="addsection btn btn-success" ng-click="addsection()" style="position:relative; bottom: 0;">add section</button> </div> <div > <div class="tab-pane" ng-class="{active : issectionselected(section)}" id="{{section.id}}" ng-repeat="section in sections"> </div> </div> <div ng-view></div> </body> every object in array has array called roots , button, named add root, want push objects(elements) whatever section on, depending on $routeparams id variable.
$scope.addroot = function(section){ section.roots.push({ id: $scope.counter++, name: 'random root', }); }; html template called router
<script type="text/ng-template" id="/tpl.html"> <div class="map-container"> <div class="map"> <h2>{{section.name}}</h2> <h4>{{section.description}}</h4> <button class="add btn btn-success" ng-click="addroot(section)">add root</button> <div ng-repeat="root in section.roots" ng-include="'/tpl.html'"></div> </div> </div> </script> app.config(function ($routeprovider) { $routeprovider .when('/section', { templateurl: '/tpl.html', sectionid: '1', }) .when('/section/:sectionid', { templateurl: '/tpl.html', }) .otherwise({ redirectto: '/' }); });
Comments
Post a Comment