{"action":"created","issue":{"url":"https://api.github.com/repos/frapontillo/angular-bootstrap-switch/issues/52","labels_url":"https://api.github.com/repos/frapontillo/angular-bootstrap-switch/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/frapontillo/angular-bootstrap-switch/issues/52/comments","events_url":"https://api.github.com/repos/frapontillo/angular-bootstrap-switch/issues/52/events","html_url":"https://github.com/frapontillo/angular-bootstrap-switch/issues/52","id":52124267,"number":52,"title":"A switch that is not visible on page load will not be properly initialized","user":{"login":"Splaktar","id":3506071,"avatar_url":"https://avatars.githubusercontent.com/u/3506071?v=3","gravatar_id":"","url":"https://api.github.com/users/Splaktar","html_url":"https://github.com/Splaktar","followers_url":"https://api.github.com/users/Splaktar/followers","following_url":"https://api.github.com/users/Splaktar/following{/other_user}","gists_url":"https://api.github.com/users/Splaktar/gists{/gist_id}","starred_url":"https://api.github.com/users/Splaktar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Splaktar/subscriptions","organizations_url":"https://api.github.com/users/Splaktar/orgs","repos_url":"https://api.github.com/users/Splaktar/repos","events_url":"https://api.github.com/users/Splaktar/events{/privacy}","received_events_url":"https://api.github.com/users/Splaktar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/frapontillo/angular-bootstrap-switch/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2014-12-16T15:11:30Z","updated_at":"2015-03-23T21:12:23Z","closed_at":null,"body":"Using:\r\nbootstrap-switch: v3.0.2\r\nangular-bootstrap-switch: v0.4.0-alpha.1 - 2014-11-21\r\nangularjs: 1.3.6\r\n\r\nIf the switch is within a tab that isn't initially visible, then it will not be initialized properly with the value of its ng-model. This is also true with other components that contain/hide the switch like angular-wizard, angular-material tabs (md-tab), etc.\r\n\r\nThe `scope.$watch(attrs.ngModel, function (newValue) {` is called properly and sets the state on the element. Later when the element becomes visible, the value is correct but the display state is not.\r\n\r\nWe're currently working around the issue by setting up an interval which polls to see when the element becomes visible and then makes the call to:\r\n\r\n`element.bootstrapSwitch('state', newValue === getTrueValue(), true);`\r\n\r\nThis seems to set both the value and display state properly so that they stay in sync, There is likely a better solution.\r\n\r\nThis does not appear to be covered by an existing test since I was able to clone the project and run the Karma tests with AngularJS 1.3.6. They all passed."},"comment":{"url":"https://api.github.com/repos/frapontillo/angular-bootstrap-switch/issues/comments/85199544","html_url":"https://github.com/frapontillo/angular-bootstrap-switch/issues/52#issuecomment-85199544","issue_url":"https://api.github.com/repos/frapontillo/angular-bootstrap-switch/issues/52","id":85199544,"user":{"login":"treyhoover","id":10567194,"avatar_url":"https://avatars.githubusercontent.com/u/10567194?v=3","gravatar_id":"","url":"https://api.github.com/users/treyhoover","html_url":"https://github.com/treyhoover","followers_url":"https://api.github.com/users/treyhoover/followers","following_url":"https://api.github.com/users/treyhoover/following{/other_user}","gists_url":"https://api.github.com/users/treyhoover/gists{/gist_id}","starred_url":"https://api.github.com/users/treyhoover/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treyhoover/subscriptions","organizations_url":"https://api.github.com/users/treyhoover/orgs","repos_url":"https://api.github.com/users/treyhoover/repos","events_url":"https://api.github.com/users/treyhoover/events{/privacy}","received_events_url":"https://api.github.com/users/treyhoover/received_events","type":"User","site_admin":false},"created_at":"2015-03-23T21:12:23Z","updated_at":"2015-03-23T21:12:23Z","body":"Has there been any progress on this? I'm facing the same issue."}}