{"action":"created","issue":{"url":"https://api.github.com/repos/angular/router/issues/100","labels_url":"https://api.github.com/repos/angular/router/issues/100/labels{/name}","comments_url":"https://api.github.com/repos/angular/router/issues/100/comments","events_url":"https://api.github.com/repos/angular/router/issues/100/events","html_url":"https://github.com/angular/router/issues/100","id":57734562,"number":100,"title":"What is the `resolve` equivalent in the new router?","user":{"login":"PascalPrecht","id":445106,"avatar_url":"https://avatars.githubusercontent.com/u/445106?v=3","gravatar_id":"","url":"https://api.github.com/users/PascalPrecht","html_url":"https://github.com/PascalPrecht","followers_url":"https://api.github.com/users/PascalPrecht/followers","following_url":"https://api.github.com/users/PascalPrecht/following{/other_user}","gists_url":"https://api.github.com/users/PascalPrecht/gists{/gist_id}","starred_url":"https://api.github.com/users/PascalPrecht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PascalPrecht/subscriptions","organizations_url":"https://api.github.com/users/PascalPrecht/orgs","repos_url":"https://api.github.com/users/PascalPrecht/repos","events_url":"https://api.github.com/users/PascalPrecht/events{/privacy}","received_events_url":"https://api.github.com/users/PascalPrecht/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/router/labels/type:%20docs","name":"type: docs","color":"bfe5bf"},{"url":"https://api.github.com/repos/angular/router/labels/type:%20question","name":"type: question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/angular/router/milestones/9","html_url":"https://github.com/angular/router/milestones/v0.6.0","labels_url":"https://api.github.com/repos/angular/router/milestones/9/labels","id":1025008,"number":9,"title":"v0.6.0","description":"","creator":{"login":"btford","id":474988,"avatar_url":"https://avatars.githubusercontent.com/u/474988?v=3","gravatar_id":"","url":"https://api.github.com/users/btford","html_url":"https://github.com/btford","followers_url":"https://api.github.com/users/btford/followers","following_url":"https://api.github.com/users/btford/following{/other_user}","gists_url":"https://api.github.com/users/btford/gists{/gist_id}","starred_url":"https://api.github.com/users/btford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btford/subscriptions","organizations_url":"https://api.github.com/users/btford/orgs","repos_url":"https://api.github.com/users/btford/repos","events_url":"https://api.github.com/users/btford/events{/privacy}","received_events_url":"https://api.github.com/users/btford/received_events","type":"User","site_admin":false},"open_issues":24,"closed_issues":5,"state":"open","created_at":"2015-03-17T08:57:24Z","updated_at":"2015-04-13T23:13:36Z","due_on":"2015-04-14T07:00:00Z","closed_at":null},"comments":28,"created_at":"2015-02-15T15:51:30Z","updated_at":"2015-05-14T04:45:22Z","closed_at":null,"body":"I read the source code and also the existing documentation you wrote for the router. Since I try to also sort of compare the old with the new router in the article, I need to explain the `resolve` $routeProvider config equivalent of the new router.\r\n\r\nAs far as I understand, instead of having this `resolve` block, we use `canActivate` and `activate` for it. Am I getting this right?\r\n\r\nWhereas `canActivate` decides with the routing happens at all, `activate` is in charge of doing all the work that is needed to make needed data available in the controller. As you show in the docs, this could be something like:\r\n\r\n```js\r\nMyController.prototype.activate = function() {\r\n  return this.bigFiles = this.$http.downloadBigFiles();\r\n};\r\n```\r\n`this.bigFiles` is what we usually would request in a `resolve` block. Please correct me if I'm wrong.\r\n\r\nHowever, I still wonder how this behaves, if we have asynchronous work todo (actually the example looks asynchronous too). In the old router, `resolve` properties were injected into the controller that is associated to the view.\r\n\r\nI understand that we don't need that anymore, as long as we just expose data on `this` (in the example `this.bigFiles`), since controller methods can just access it. But what if we have a promise, that needs to resolve first? Is that functionality also (still) supported in the new router?\r\n\r\nHope my question is clear."},"comment":{"url":"https://api.github.com/repos/angular/router/issues/comments/101907740","html_url":"https://github.com/angular/router/issues/100#issuecomment-101907740","issue_url":"https://api.github.com/repos/angular/router/issues/100","id":101907740,"user":{"login":"paulwalker","id":73511,"avatar_url":"https://avatars.githubusercontent.com/u/73511?v=3","gravatar_id":"","url":"https://api.github.com/users/paulwalker","html_url":"https://github.com/paulwalker","followers_url":"https://api.github.com/users/paulwalker/followers","following_url":"https://api.github.com/users/paulwalker/following{/other_user}","gists_url":"https://api.github.com/users/paulwalker/gists{/gist_id}","starred_url":"https://api.github.com/users/paulwalker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulwalker/subscriptions","organizations_url":"https://api.github.com/users/paulwalker/orgs","repos_url":"https://api.github.com/users/paulwalker/repos","events_url":"https://api.github.com/users/paulwalker/events{/privacy}","received_events_url":"https://api.github.com/users/paulwalker/received_events","type":"User","site_admin":false},"created_at":"2015-05-14T04:45:22Z","updated_at":"2015-05-14T04:45:22Z","body":"Right, I just don't want to have to contain that logic in every controller. This is where something like ui-router's $stateChangeStart event is helpful, allowing one to annotate the route with a particular common security context is helpful.\r\n\r\n```\r\n$rootScope.$on('$stateChangeStart', \r\nfunction(event, toState, toParams, fromState, fromParams){ \r\n    event.preventDefault(); \r\n    // transitionTo() promise will be rejected with \r\n    // a 'transition prevented' error\r\n})\r\n```"}}