Hi,

I've posted some boiled down code, which causes an infinite loop, at the 
bottom of this message, and here:

http://stackoverflow.com/questions/21631896/why-does-this-angular-ui-router-code-cause-an-infinite-loop-in-digest

I'm wondering if I used the UI router incorrectly, or if I need to file a 
bug. 

thanks,
Rob

    <!doctype html>
    <html ng-app='bugapp' ng-controller='BugAppCtrl'>
    <head>
      <script src='//code.jquery.com/jquery-1.10.1.min.js'></script>
    
      <!-- Angular 1.2.11 -->
      <script 
src='//ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.js'></script>
      <!--<script 
src='/rrmembers/static/common/angular/angular.js'></script> -->
    
      <!-- UI router 0.2.8 -->
      <script 
src='//cdn.jsdelivr.net/angular.ui-router/0.2.8/angular-ui-router.js'></script>
      <!-- <script 
src='/rrmembers/static/common/angular/angular-ui-router-0.2.8.js'></script> 
-->
    
      <script>
    angular.module('bugapp', ['ui.router'])
      .run(function ($rootScope, $state, $stateParams) {
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams;
      })
      .config(function ($locationProvider, $stateProvider, 
$urlRouterProvider) {
        $locationProvider.html5Mode(false);
    
        $stateProvider
          .state("root", {
            abstract: true,
            url: "/servletContext?asUser",
            template: '<div ui-view></div>'  // ???
          })
          .state("root.home", {
            abstract: true,
            url: "/home",
            template: "<div ng-if='hasData()' ui-view ></div>"
    
          })
          .state("root.home.profile", {
            url: "/profile",
            template: '<div>whatever</div>'
          })
    
      })
      .controller('BugAppCtrl', function ($scope, $state, $stateParams, 
$log, $location) {
        $log.log('BugAppCtrl: constructor 6');
    
        $scope.hasData = function() {
          var res = !!$scope.foo;
          // $log.log("hasData called, returing " + res + " foo is " + 
$scope.foo);
          return res;
        };
    
        $scope.$on('$stateChangeSuccess', function () {
          $log.log("State changed! (to " + $state.current.name + ")");
          $scope.foo = 'junk';
          $scope.$broadcast("resetfoo");
        });
    
        $state.go('root.home.profile');
      });
      </script>
    </head>
    <body>
      <div ui-view></div>
    </body>
    </html>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to