Skip to content

Resolve called twice #37

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

Closed
ffesseler opened this issue Feb 27, 2013 · 2 comments
Closed

Resolve called twice #37

ffesseler opened this issue Feb 27, 2013 · 2 comments

Comments

@ffesseler
Copy link

Using the sample app you provide :

.state('about', {
          url: '/about',
          resolve: {
            something: function() {
              console.log('about');
            }
          },
          templateProvider:
            ['$timeout',
            function ($timeout) {
              return $timeout(function () { return "Hello world" }, 100);
            }],
        });

console.log is called twice.
It doesn't happen when using views property on state though :

state('contacts.detail', {
          // parent: 'contacts',
          url: '/{contactId}',
          resolve: {
            something: function() {
              console.log('only called once');
            }
          },
          views: {
            '': {
              templateUrl: 'contacts.detail.html',
              controller:
                [        '$scope', '$stateParams', 'something',
                function ($scope,   $stateParams,   something) {
                  $scope.something = something;
                  $scope.contact = findById($scope.contacts, $stateParams.contactId);
                }],
            },
            'hint@': {
              template: 'This is contacts.detail populating the view "hint@"',
            },
            'menu': {
              templateProvider:
                [ '$stateParams',
                function ($stateParams){
                  // This is just to demonstrate that $stateParams injection works for templateProvider
                  // $stateParams are the parameters for the new state we're transitioning to, even
                  // though the global '$stateParams' has not been updated yet.
                  return '<hr><small class="muted">Contact ID: ' + $stateParams.contactId + '</small>';
                }],
            },
          },
        })
@ffesseler
Copy link
Author

Thanks, will have a try today!

@ffesseler
Copy link
Author

Works well ;-)

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

2 participants