{"action":"created","issue":{"url":"https://api.github.com/repos/Urigo/angular-meteor/issues/484","labels_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/484/labels{/name}","comments_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/484/comments","events_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/484/events","html_url":"https://github.com/Urigo/angular-meteor/issues/484","id":92658023,"number":484,"title":"How do I know if $scope.$meteorObject(id) found an object or not?","user":{"login":"pgrm","id":713456,"avatar_url":"https://avatars.githubusercontent.com/u/713456?v=3","gravatar_id":"","url":"https://api.github.com/users/pgrm","html_url":"https://github.com/pgrm","followers_url":"https://api.github.com/users/pgrm/followers","following_url":"https://api.github.com/users/pgrm/following{/other_user}","gists_url":"https://api.github.com/users/pgrm/gists{/gist_id}","starred_url":"https://api.github.com/users/pgrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgrm/subscriptions","organizations_url":"https://api.github.com/users/pgrm/orgs","repos_url":"https://api.github.com/users/pgrm/repos","events_url":"https://api.github.com/users/pgrm/events{/privacy}","received_events_url":"https://api.github.com/users/pgrm/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-07-02T14:55:03Z","updated_at":"2015-07-04T09:49:16Z","closed_at":"2015-07-03T00:01:09Z","body":"Hi, great framework, which I still need to wrap my head around a bit.\r\n\r\nI have a `ListController` and an `ItemController`. The `ItemController` is in a nested state of the `ListController` it loads the item details and by doing this, it also checks if the item actually exists. If the item doesn't exist, the `ItemController` redirects back to the root state.\r\n\r\nThis is what I have so far:\r\n\r\n    this.current = $scope.$meteorObject(Items, $state.params['itemId']);\r\n    if (!this.current._id) { \r\n        $state.go('^'); \r\n    } else { \r\n        /* initialize everything */ \r\n    }\r\n\r\nIf I type in a wrong id on purpose it works. If I type in the correct id, it also works. But if refresh the browser, `this.current._id` is undefined even though, the id was correct.\r\n\r\nI've tried using `$scope.subscribe` but the promise was never called. My `ItemsController` contains the is running subscribe on the `Items` collection:\r\n\r\n\tthis.items = $scope.$meteorCollection(Items);\r\n\tthis.items.subscribe('items');\r\n\r\nI thought $meteorObject would be synchronous but I guess there are some exceptions to it? Or is my code completely wrong?"},"comment":{"url":"https://api.github.com/repos/Urigo/angular-meteor/issues/comments/118494397","html_url":"https://github.com/Urigo/angular-meteor/issues/484#issuecomment-118494397","issue_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/484","id":118494397,"user":{"login":"pgrm","id":713456,"avatar_url":"https://avatars.githubusercontent.com/u/713456?v=3","gravatar_id":"","url":"https://api.github.com/users/pgrm","html_url":"https://github.com/pgrm","followers_url":"https://api.github.com/users/pgrm/followers","following_url":"https://api.github.com/users/pgrm/following{/other_user}","gists_url":"https://api.github.com/users/pgrm/gists{/gist_id}","starred_url":"https://api.github.com/users/pgrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgrm/subscriptions","organizations_url":"https://api.github.com/users/pgrm/orgs","repos_url":"https://api.github.com/users/pgrm/repos","events_url":"https://api.github.com/users/pgrm/events{/privacy}","received_events_url":"https://api.github.com/users/pgrm/received_events","type":"User","site_admin":false},"created_at":"2015-07-04T09:49:16Z","updated_at":"2015-07-04T09:49:16Z","body":"@Urigo your suggested solution with `$meteor.subscribe` in resolve would need me to stop the subscription, when the controller (scope) is being destroyed, otherwise I'd end up with memory leaks, is that correct?\r\n\r\nIn that case there wouldn't be too much difference between running `$scope.meteorSubscribe` and handle the rest of the initialisation inside the promise callback, or making sure the controller listens to `$destroy` on it's scope to stop the handle. "}}