{"action":"created","issue":{"url":"https://api.github.com/repos/angular-ui/ui-router/issues/1901","labels_url":"https://api.github.com/repos/angular-ui/ui-router/issues/1901/labels{/name}","comments_url":"https://api.github.com/repos/angular-ui/ui-router/issues/1901/comments","events_url":"https://api.github.com/repos/angular-ui/ui-router/issues/1901/events","html_url":"https://github.com/angular-ui/ui-router/issues/1901","id":69948266,"number":1901,"title":"bug fix proposed","user":{"login":"vladsd","id":3460517,"avatar_url":"https://avatars.githubusercontent.com/u/3460517?v=3","gravatar_id":"","url":"https://api.github.com/users/vladsd","html_url":"https://github.com/vladsd","followers_url":"https://api.github.com/users/vladsd/followers","following_url":"https://api.github.com/users/vladsd/following{/other_user}","gists_url":"https://api.github.com/users/vladsd/gists{/gist_id}","starred_url":"https://api.github.com/users/vladsd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladsd/subscriptions","organizations_url":"https://api.github.com/users/vladsd/orgs","repos_url":"https://api.github.com/users/vladsd/repos","events_url":"https://api.github.com/users/vladsd/events{/privacy}","received_events_url":"https://api.github.com/users/vladsd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular-ui/ui-router/labels/bug","name":"bug","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-04-21T20:49:29Z","updated_at":"2015-11-10T11:40:35Z","closed_at":null,"body":"sometime locals var in current state is null. the code below throws exception:\r\n\r\n```\r\n function updateView(firstTime) {\r\n          var newScope,\r\n              name            = getUiViewName(scope, attrs, $element, $interpolate),\r\n              previousLocals  = name && $state.$current && $state.$current.locals[name];\r\n if (!firstTime && previousLocals === latestLocals) return; // nothing to do\r\n          newScope = scope.$new();\r\n          latestLocals = $state.$current.locals[name];\r\n```\r\n\r\n\r\nPROPOSED CODE:\r\n // BUG FIX\r\n\r\n```\r\n            var newScope,\r\n                name = getUiViewName(scope, attrs, $element, $interpolate);\r\n            var previousLocals = null;\r\n            if (name && $state.$current && $state.$current.locals)\r\n                previousLocals = name && $state.$current && $state.$current.locals[name];\r\n\r\n          if (!firstTime && previousLocals === latestLocals) return; // nothing to do\r\n          newScope = scope.$new();\r\n            // BUG FIX\r\n          if ($state.$current.locals)\r\n            latestLocals = $state.$current.locals[name];\r\n```\r\n\r\nanother place where locals are referenced without checking for null is:\r\n\r\n```\r\nvar current = $state.$current,\r\n            name = getUiViewName(scope, attrs, $element, $interpolate),\r\n            locals  = current && current.locals[name];\r\n```\r\n\r\nand fix \r\n\r\n```\r\n        var current = $state.$current,\r\n            name = getUiViewName(scope, attrs, $element, $interpolate);\r\n        var locals = null;\r\n        if (current && current.locals)\r\n            locals = current && current.locals[name];\r\n\r\n        if (! locals) {\r\n          return;\r\n        }\r\n```"},"comment":{"url":"https://api.github.com/repos/angular-ui/ui-router/issues/comments/155397069","html_url":"https://github.com/angular-ui/ui-router/issues/1901#issuecomment-155397069","issue_url":"https://api.github.com/repos/angular-ui/ui-router/issues/1901","id":155397069,"user":{"login":"eldereal","id":1592754,"avatar_url":"https://avatars.githubusercontent.com/u/1592754?v=3","gravatar_id":"","url":"https://api.github.com/users/eldereal","html_url":"https://github.com/eldereal","followers_url":"https://api.github.com/users/eldereal/followers","following_url":"https://api.github.com/users/eldereal/following{/other_user}","gists_url":"https://api.github.com/users/eldereal/gists{/gist_id}","starred_url":"https://api.github.com/users/eldereal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eldereal/subscriptions","organizations_url":"https://api.github.com/users/eldereal/orgs","repos_url":"https://api.github.com/users/eldereal/repos","events_url":"https://api.github.com/users/eldereal/events{/privacy}","received_events_url":"https://api.github.com/users/eldereal/received_events","type":"User","site_admin":false},"created_at":"2015-11-10T11:40:35Z","updated_at":"2015-11-10T11:40:35Z","body":"Is there any updates on this issue? I had face the same problem when trying to use `$state.go(...)` in `onEnter` callback. Now I use `$timeout` to workaround with this problem.\r\n```javascript\r\nonEnter: [\"$state\", \"$timeout\", function($state, $timeout){      \r\n    $timeout(function(){\r\n        $state.go(...);\r\n    });\r\n}]\r\n```\r\nIt works but the code is not beautiful."}}