Coder Social home page Coder Social logo

Comments (6)

thirionjwf avatar thirionjwf commented on June 16, 2024

Here is the relevant code snippets:

.controller('MyCtrl', function ($scope, $state, AuthService, $multiStepForm) {
    $scope.reset = function() {
        $scope.model = {};
    }

    $scope.logout = function () {
        $multiStepFormInstance.setActiveIndex(1);
        AuthService.logout();
        $state.go('login');
    };

   ....
})
<ion-view view-title="StepsTab" name="step-tabs-view">
    <ion-nav-buttons side="right">
        <button class="button icon ion-log-out button-stable" ng-click="logout()"></button>
    </ion-nav-buttons>

    <ion-content class="padding">
        <multi-step-container steps="steps">
            <header>
                <div id="status-buttons" class="text-center">
                    <a ng-class="$getActiveStep().title == 'Step1' ? 'active' : ''"><span>1</span> Step 1</a>
                    <a ng-class="$getActiveStep().title == 'Step2' ? 'active' : ''"><span>2</span> Step 2</a>
                    <a ng-class="$getActiveStep().title == 'Step3' ? 'active' : ''"><span>3</span> Step 3</a>
                </div>

                <div class="stepHeading">
                    {{$getActiveStep().title}}
                </div>

                <div style="{{$isLast() ? 'display: none' : ''}}">
                    <br>
                    <button ng-disabled="$isFirst()" class="button button-small button-stable ion-chevron-left" ng-click="$previousStep()">
                        Previous
                    </button>
                    <button ng-disabled="$isLast() || ($getActiveStep().hasForm && !$getActiveStep().valid)" class="button button-small button-stable icon-right ion-chevron-right" ng-click="$nextStep()">Next
                    </button>
                </div>

                <div style="{{$isLast() ? '' : 'display: none'}}">
                    <br>
                    <button class="button button-small button-stable" ng-click="reset(); $setActiveIndex(1)">Done
                    </button>
                </div>
            </header>

            <br>

            <main step-container></main>
        </multi-step-container>
    </ion-content>
</ion-view>

from angular-multi-step-form.

troch avatar troch commented on June 16, 2024

Hi @thirionjwf,

You are not doing anything wrong. You cannot inject multiStepInstance outside the directive because it is not available application wide (it is specific to that instance).

Currently it is not possible to control a multiStepForm instance from outside the directive. I can work on a solution, however from an application perspective I would encourage you to destroy the multiStepForm instance and create a new one rather than trying to go back to step 1 (which is not a proper "reset").

You can simply destroy the directive by forcing a reload of your view. That would reset the multi-step form.

from angular-multi-step-form.

thirionjwf avatar thirionjwf commented on June 16, 2024

Thank you. I assume you refer to something like:

$scope.reloadRoute = function() {
$route.reload();
}

which will reload the current route. Or would the form instance only get destroyed on a full refresh, i.e.:

$scope.reloadRoute = function() {
$window.location.reload();
}

Great plugin. Works very well.

from angular-multi-step-form.

troch avatar troch commented on June 16, 2024

A route reload will be enough, no need to refresh / reload the page. Not sure how do to so with <ion-view/>. It might involve $route if based on ngRoute or $state if based on ui-router.

from angular-multi-step-form.

thirionjwf avatar thirionjwf commented on June 16, 2024

Thanks. Much appreciated. You can close the "issue".

from angular-multi-step-form.

troch avatar troch commented on June 16, 2024

👍

from angular-multi-step-form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.