Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Results from uirouter's resolve and getList().then() are similar, but not the same. #1252

Open
jondthompson opened this issue Oct 13, 2015 · 1 comment

Comments

@jondthompson
Copy link

The following two code snippets should result in the same data, but one is loaded prior to the state change and the other is loaded asynchronously. They're not. ng-repeat works with both of them, but I switched to angular-utils-pagination, and the latter code works, but the former code does not.

However, I don't see a difference in the arrays that are being generated, and they work with ng-repeat.
I'm going to crosspost this issue to angular-utils-pagination and ui-router as well, as it's not handling the difference properly, as I'm not certain whether uirouter or restangular is in error for giving the wrong information in the first place.

doesn't work with angular-utils-pagination

.state( 'users', {
    url:'/users',
    controller: 'UsersCtrl',
    templateUrl: 'users/Users.tpl.html',
    data:{ pageTitle: 'Users' },
    authenticate: true,
    resolve: {
      users: ['Users', function(Users){
        return Users.getList({embed:'roles,user_certifications'});
      }]
    }
  })
.controller( 'UsersCtrl', function UsersController( $scope, users ) {
  $scope.users = users;
})
.factory('Users', function(Restangular){
  return Restangular.service('users');
})
;

works with angular-utils-pagination

.state( 'users', {
    url:'/users',
    controller: 'UsersCtrl',
    templateUrl: 'users/Users.tpl.html',
    data:{ pageTitle: 'Users' },
    authenticate: true
  })
.controller( 'UsersCtrl', function UsersController( $scope, Users ) {
  Users.getList().then(function(result){
   $scope.users = result;
   });
})
.factory('Users', function(Restangular){
  return Restangular.service('users');
})
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant