{"action":"created","issue":{"url":"https://api.github.com/repos/driftyco/ionic/issues/4089","repository_url":"https://api.github.com/repos/driftyco/ionic","labels_url":"https://api.github.com/repos/driftyco/ionic/issues/4089/labels{/name}","comments_url":"https://api.github.com/repos/driftyco/ionic/issues/4089/comments","events_url":"https://api.github.com/repos/driftyco/ionic/issues/4089/events","html_url":"https://github.com/driftyco/ionic/issues/4089","id":95242586,"number":4089,"title":"bug: Controller executing twice - nested states.","user":{"login":"Leftyx","id":171024,"avatar_url":"https://avatars.githubusercontent.com/u/171024?v=3","gravatar_id":"","url":"https://api.github.com/users/Leftyx","html_url":"https://github.com/Leftyx","followers_url":"https://api.github.com/users/Leftyx/followers","following_url":"https://api.github.com/users/Leftyx/following{/other_user}","gists_url":"https://api.github.com/users/Leftyx/gists{/gist_id}","starred_url":"https://api.github.com/users/Leftyx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Leftyx/subscriptions","organizations_url":"https://api.github.com/users/Leftyx/orgs","repos_url":"https://api.github.com/users/Leftyx/repos","events_url":"https://api.github.com/users/Leftyx/events{/privacy}","received_events_url":"https://api.github.com/users/Leftyx/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/driftyco/ionic/labels/ionitron:closed","name":"ionitron:closed","color":"c7def8"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2015-07-15T17:01:49Z","updated_at":"2016-10-25T09:17:15Z","closed_at":"2015-10-13T18:17:44Z","body":"**Type**: <span ionic-type>bug</span>\r\n\r\n**Platform**: <span ionic-platform>all</span>  \r\n\r\n<span ionic-description>Nested states with parameters and tabs execute the controller twice.\r\n\r\nHow to reproduce:\r\n\r\nThe first state manages the tabs \r\n\r\n```\r\n  .state('tabs', {\r\n      url: \"/tab/:projectID\",\r\n      cache: false,\r\n      templateUrl: \"tabs.html\",\r\n      controller: \"TabsCtrl  as vm\",\r\n      resolve: {\r\n        project: function($stateParams, Projects) {\r\n          return Projects.get($stateParams.projectID);\r\n        }\r\n      }\r\n  })\r\n\r\n  .state('tabs.tab1', {\r\n      url: \"/tab1\",\r\n      views: {\r\n          'tabs-tab1': {\r\n              templateUrl: \"tab1.html\",\r\n              controller: 'Tab1Ctrl as vm'\r\n          }\r\n      }\r\n  })\r\n\r\n```\r\nthe seconds loads the specific tabs in the tab list.\r\n\r\nPlunker [here](http://plnkr.co/edit/3al3x1OVlZ1qXabWz36H?p=preview).\r\n\r\nQuestion asked on [StackOverflow](http://stackoverflow.com/questions/31392469/controller-executing-twice-with-ui-router-nested-states-ionic).\r\n</span>\r\n\r\n<span is-issue-template></span>\r\n"},"comment":{"url":"https://api.github.com/repos/driftyco/ionic/issues/comments/255981982","html_url":"https://github.com/driftyco/ionic/issues/4089#issuecomment-255981982","issue_url":"https://api.github.com/repos/driftyco/ionic/issues/4089","id":255981982,"user":{"login":"jachstet-sea","id":7993508,"avatar_url":"https://avatars.githubusercontent.com/u/7993508?v=3","gravatar_id":"","url":"https://api.github.com/users/jachstet-sea","html_url":"https://github.com/jachstet-sea","followers_url":"https://api.github.com/users/jachstet-sea/followers","following_url":"https://api.github.com/users/jachstet-sea/following{/other_user}","gists_url":"https://api.github.com/users/jachstet-sea/gists{/gist_id}","starred_url":"https://api.github.com/users/jachstet-sea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jachstet-sea/subscriptions","organizations_url":"https://api.github.com/users/jachstet-sea/orgs","repos_url":"https://api.github.com/users/jachstet-sea/repos","events_url":"https://api.github.com/users/jachstet-sea/events{/privacy}","received_events_url":"https://api.github.com/users/jachstet-sea/received_events","type":"User","site_admin":false},"created_at":"2016-10-25T09:17:15Z","updated_at":"2016-10-25T09:17:15Z","body":"Oh, and to not come here empty-handed: In the application where I have the same problem, I added a console.trace() to the controller's constructor. The interesting thing is that the trace is different for the two calls. So I added the console.trace() to the plunkr as well: http://plnker.co/edit/xJ6WBLubrx4bCbJmCqNE?p=preview\r\nThe one trace contains the lines:\r\n`$RootScopeProvider/this.$get</Scope.prototype.$broadcast()ionic.bundle.js:30717\r\ntransitionTo/$state.transition<()`\r\nThe other one these lines:\r\n`publicLinkFn()ionic.bundle.js:21582\r\ntabSelected()`\r\n\r\nSo while the one constructor is directly triggered by the switching of the tabs, the other one seems to be triggered by the URL/state change which itself is triggered by the tab click.\r\n\r\nMaybe one of those events should be prevented when clicking on a tab?"}}
{"actor":{"display_login":"jachstet-sea"}}