{"action":"created","issue":{"url":"https://api.github.com/repos/driftyco/ionic/issues/3551","labels_url":"https://api.github.com/repos/driftyco/ionic/issues/3551/labels{/name}","comments_url":"https://api.github.com/repos/driftyco/ionic/issues/3551/comments","events_url":"https://api.github.com/repos/driftyco/ionic/issues/3551/events","html_url":"https://github.com/driftyco/ionic/issues/3551","id":69301363,"number":3551,"title":"$stateChangeSuccess and $ionicHistory wrong $stateParams","user":{"login":"akreienbring","id":9348725,"avatar_url":"https://avatars.githubusercontent.com/u/9348725?v=3","gravatar_id":"","url":"https://api.github.com/users/akreienbring","html_url":"https://github.com/akreienbring","followers_url":"https://api.github.com/users/akreienbring/followers","following_url":"https://api.github.com/users/akreienbring/following{/other_user}","gists_url":"https://api.github.com/users/akreienbring/gists{/gist_id}","starred_url":"https://api.github.com/users/akreienbring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akreienbring/subscriptions","organizations_url":"https://api.github.com/users/akreienbring/orgs","repos_url":"https://api.github.com/users/akreienbring/repos","events_url":"https://api.github.com/users/akreienbring/events{/privacy}","received_events_url":"https://api.github.com/users/akreienbring/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-18T11:36:32Z","updated_at":"2015-04-18T11:36:34Z","closed_at":null,"body":"I came across an issue that puzzeld me for 2 days now.\r\nIt consists of 2 issues but they may be related to the same rootcause.\r\n\r\nI configured 2 states like this:\r\n```\r\n\t.state('tab', {\r\n\t\turl: \"/tab\",\r\n\t\tabstract: true,\r\n\t\ttemplateUrl: \"templates/menu.html\",\r\n\t\tcontroller: \"MenuCtrl\"\r\n\t})\r\n\t.state('tab.location', {\r\n\t\tcache: false,\r\n\t\turl: '/beacon',\r\n\t\tparams: {beaconUser:{}, beacon:{}},\t\t\r\n\t\tviews: {\r\n\t\t\t'menuContent': {\r\n\t\t\t\ttemplateUrl: 'templates/Beacon.html',\r\n\t\t\t\tcontroller: 'BeaconCtrl'\r\n\t\t\t}\r\n\t\t},\r\n\t})\r\n       .state('tab.chat', {\r\n\t     cache: false,\r\n    \t     url: '/chat',\r\n\t     params: {chatUserId:{}},\t\t\r\n    \t     views: {\r\n    \t\t    'menuContent': {\r\n    \t\t\t    templateUrl: 'templates/Chat.html',\r\n    \t\t\t    controller: 'ChatCtrl'\r\n    \t\t    }\r\n    \t     }\r\n        })\r\n```\r\nFirst I navigate to the location state like this:\r\n````\r\nui-sref=\"tab.location({locationUser: user})\"\r\n```\r\nand from there to the chat state like this:\r\n````\r\nui-sref=\"tab.chat({chatUserId: userid})\"\r\n```\r\n\r\nFirst issue:\r\nregistering a listener to $stateChangeSuccess during the run method of a module\r\n```\r\n\t$rootScope.$on('$stateChangeSuccess',function(event, toState, toParams, fromState, fromParams){\r\n\t\tif(toState.name == \"tab.chat\"){\r\n\t\t\t$ionicHistory.backView().stateParams //undefined\t\r\n\t\t};\r\n\t});\r\n```\r\nnote that $ionicHistory.backView().stateParams is undefined. Whereas registering the same listener in a controller\r\n```\r\n\t$scope.$on('$stateChangeSuccess',function(event, toState, toParams, fromState, fromParams){\r\n\t\tif(toState.name == \"tab.chat\"){\r\n\t\t\t$ionicHistory.backView().stateParams //defined\t\r\n\t\t};\r\n\t});\r\n\r\n```\r\n$ionicHistory.backView().stateParams is existing!\r\n\r\nOn to the second issue...\r\n\r\nEven on the controller level the stateParams in history are incorrect. I would expect them to be exactly the same as the fromParams, but they aren't.\r\nthis offcourse leeds to an incorrect behaviour of my app when pressing the back button and going back to the location state.\r\nFor the time being I fixed that by \r\n```\r\n\t$scope.$on('$stateChangeSuccess',function(event, toState, toParams, fromState, fromParams){\r\n\t\tif(toState.name == \"tab.chat\"){\r\n\t\t\t$ionicHistory.backView().stateParams = fromParams\r\n\t\t};\r\n\t});\r\n\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/driftyco/ionic/issues/comments/94158773","html_url":"https://github.com/driftyco/ionic/issues/3551#issuecomment-94158773","issue_url":"https://api.github.com/repos/driftyco/ionic/issues/3551","id":94158773,"user":{"login":"Ionitron","id":6591344,"avatar_url":"https://avatars.githubusercontent.com/u/6591344?v=3","gravatar_id":"","url":"https://api.github.com/users/Ionitron","html_url":"https://github.com/Ionitron","followers_url":"https://api.github.com/users/Ionitron/followers","following_url":"https://api.github.com/users/Ionitron/following{/other_user}","gists_url":"https://api.github.com/users/Ionitron/gists{/gist_id}","starred_url":"https://api.github.com/users/Ionitron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ionitron/subscriptions","organizations_url":"https://api.github.com/users/Ionitron/orgs","repos_url":"https://api.github.com/users/Ionitron/repos","events_url":"https://api.github.com/users/Ionitron/events{/privacy}","received_events_url":"https://api.github.com/users/Ionitron/received_events","type":"User","site_admin":false},"created_at":"2015-04-18T11:36:34Z","updated_at":"2015-04-18T11:36:34Z","body":"Greetings @akreienbring!\n\nMy sensors indicate that you need to update your issue through our [custom issue form](http://ionicframework.com/submit-issue/#/?iid=3551). We are now requiring all issues to be submitted this way, to ensure that we have all of the information necessary to fix them as quickly as possible.\n\n**[Click Here To Update Your Issue](http://ionicframework.com/submit-issue/#/?iid=3551)**\n\nI will have no choice but to close this issue if it is not resubmitted through the form. Please fill out the rest of the form, so that I may use my friendly robot powers to assist you.\n\nThank you!\n\n<span ionitron-issue-resubmit></span>"}}