{"action":"created","issue":{"url":"https://api.github.com/repos/troch/angular-multi-step-form/issues/7","labels_url":"https://api.github.com/repos/troch/angular-multi-step-form/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/troch/angular-multi-step-form/issues/7/comments","events_url":"https://api.github.com/repos/troch/angular-multi-step-form/issues/7/events","html_url":"https://github.com/troch/angular-multi-step-form/issues/7","id":105574718,"number":7,"title":"Controlling an angular-multi-step-form from a controller (changing step index)","user":{"login":"thirionjwf","id":14197309,"avatar_url":"https://avatars.githubusercontent.com/u/14197309?v=3","gravatar_id":"","url":"https://api.github.com/users/thirionjwf","html_url":"https://github.com/thirionjwf","followers_url":"https://api.github.com/users/thirionjwf/followers","following_url":"https://api.github.com/users/thirionjwf/following{/other_user}","gists_url":"https://api.github.com/users/thirionjwf/gists{/gist_id}","starred_url":"https://api.github.com/users/thirionjwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thirionjwf/subscriptions","organizations_url":"https://api.github.com/users/thirionjwf/orgs","repos_url":"https://api.github.com/users/thirionjwf/repos","events_url":"https://api.github.com/users/thirionjwf/events{/privacy}","received_events_url":"https://api.github.com/users/thirionjwf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-09T11:06:02Z","updated_at":"2015-09-09T11:15:29Z","closed_at":null,"body":"Hi there,\r\n\r\nI am trying to control a multi-step form from a controller. In my app a user logs in and then inside a tab view, a multi-step form is presented on one of the tabs. When user logs out with a button that is outside the multi-step-container directive, I am not able to change the step back to step 1 using $setActiveIndex(1). Hence the reason to want to change the step back to step 1 inside my logout function in the controller.\r\n\r\nIs there a way to call $setActiveIndex(1) from inside my controller? I tried adding $multiStepForm and multiStepForm as dependencies in my controller, but when I try to use it, it is undefined. I see there is a factory, but can this be used inside a controller? I must be doing something wrong here.\r\n\r\nThanks in advance!"},"comment":{"url":"https://api.github.com/repos/troch/angular-multi-step-form/issues/comments/138878510","html_url":"https://github.com/troch/angular-multi-step-form/issues/7#issuecomment-138878510","issue_url":"https://api.github.com/repos/troch/angular-multi-step-form/issues/7","id":138878510,"user":{"login":"thirionjwf","id":14197309,"avatar_url":"https://avatars.githubusercontent.com/u/14197309?v=3","gravatar_id":"","url":"https://api.github.com/users/thirionjwf","html_url":"https://github.com/thirionjwf","followers_url":"https://api.github.com/users/thirionjwf/followers","following_url":"https://api.github.com/users/thirionjwf/following{/other_user}","gists_url":"https://api.github.com/users/thirionjwf/gists{/gist_id}","starred_url":"https://api.github.com/users/thirionjwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thirionjwf/subscriptions","organizations_url":"https://api.github.com/users/thirionjwf/orgs","repos_url":"https://api.github.com/users/thirionjwf/repos","events_url":"https://api.github.com/users/thirionjwf/events{/privacy}","received_events_url":"https://api.github.com/users/thirionjwf/received_events","type":"User","site_admin":false},"created_at":"2015-09-09T11:15:29Z","updated_at":"2015-09-09T11:15:29Z","body":"Here is the relevant code snippets:\r\n\r\n.controller('MyCtrl', function ($scope, $state, AuthService, $multiStepForm) {\r\n    $scope.reset = function() {\r\n        $scope.model = {};\r\n    }\r\n\r\n    $scope.logout = function () {\r\n        $multiStepFormInstance.setActiveIndex(1);\r\n        AuthService.logout();\r\n        $state.go('login');\r\n    };\r\n\r\n   ....\r\n})\r\n\r\n\r\n\r\n<ion-view view-title=\"StepsTab\" name=\"step-tabs-view\">\r\n    <ion-nav-buttons side=\"right\">\r\n        <button class=\"button icon ion-log-out button-stable\" ng-click=\"logout()\"></button>\r\n    </ion-nav-buttons>\r\n\r\n    <ion-content class=\"padding\">\r\n        <multi-step-container steps=\"steps\">\r\n            <header>\r\n                <div id=\"status-buttons\" class=\"text-center\">\r\n                    <a ng-class=\"$getActiveStep().title == 'Step1' ? 'active' : ''\"><span>1</span> Step 1</a>\r\n                    <a ng-class=\"$getActiveStep().title == 'Step2' ? 'active' : ''\"><span>2</span> Step 2</a>\r\n                    <a ng-class=\"$getActiveStep().title == 'Step3' ? 'active' : ''\"><span>3</span> Step 3</a>\r\n                </div>\r\n\r\n                <div class=\"stepHeading\">\r\n                    {{$getActiveStep().title}}\r\n                </div>\r\n\r\n                <div style=\"{{$isLast() ? 'display: none' : ''}}\">\r\n                    <br>\r\n                    <button ng-disabled=\"$isFirst()\" class=\"button button-small button-stable ion-chevron-left\" ng-click=\"$previousStep()\">\r\n                        Previous\r\n                    </button>\r\n                    <button ng-disabled=\"$isLast() || ($getActiveStep().hasForm && !$getActiveStep().valid)\" class=\"button button-small button-stable icon-right ion-chevron-right\" ng-click=\"$nextStep()\">Next\r\n                    </button>\r\n                </div>\r\n\r\n                <div style=\"{{$isLast() ? '' : 'display: none'}}\">\r\n                    <br>\r\n                    <button class=\"button button-small button-stable\" ng-click=\"reset(); $setActiveIndex(1)\">Done\r\n                    </button>\r\n                </div>\r\n            </header>\r\n\r\n            <br>\r\n\r\n            <main step-container></main>\r\n        </multi-step-container>\r\n    </ion-content>\r\n</ion-view>"}}