Coder Social home page Coder Social logo

Comments (8)

troch avatar troch commented on June 19, 2024 1

I don't have a live example, but just injected it here: http://blog.reactandbethankful.com/angular-multi-step-form/#/saving-data (https://github.com/troch/troch.github.io/blob/master/angular-multi-step-form/scripts/app.js#L143).

Are you certain you don't use 'stepCtrl' anywhere else in your app? The error you see is typical of the controller being instantiated outside the directive.

from angular-multi-step-form.

rahul-cuelogic avatar rahul-cuelogic commented on June 19, 2024

Hi @troch

Is it possible to change step from controller method ?

from angular-multi-step-form.

troch avatar troch commented on June 19, 2024

A controller will only receive multiStepFormInstance if it is used by a <multi-step-container steps="..."></multi-step-container>. So you need to configure your steps with your controller on one of the steps, and let the directive instantiate them (it will provide them the multiStepFormInstance).

Is it possible to change step from controller method ?

I am not sure to understand your question.

from angular-multi-step-form.

rahul-cuelogic avatar rahul-cuelogic commented on June 19, 2024

Hi @troch

Here is my code, not sure what I am missing here
my store.html file is as follows in this file I am loading the steps by using the <multi-step-container> directive


<div class="wrapper-section">
  <div class="container" ng-controller="homeCtrl">

  <multi-step-container steps="storeSteps" on-cancel="$dismiss()" on-finish="$close()" search-id="'step'">

          <main step-container>



          </main>

    </multi-step-container>


  </div>
</div>

Here is my app.js file inside which I have defined homeCtrl like this:


app.controller('homeCtrl',['$scope', '$http', function($scope, $http) {


    $scope.storeSteps = [
                    {
                        templateUrl: '/app/modules/common-views/store/launch-setup.html',
                        hasForm: true,
                        controller: 'homeCtrl'
                    },
                    {
                        templateUrl: '/app/modules/common-views/store/step-one.html',
                        hasForm: true
                    },
                    {
                        templateUrl: '/app/modules/common-views/store/step-two.html',
                    },
                    {
                        templateUrl: '/app/modules/common-views/store/step-three.html',
                    },
                    {
                        templateUrl: '/app/modules/common-views/store/finish.html',
                    }

                ];

    $scope.addStore = function() {

    console.log('hello world');
    multiStepFormInstance.setActiveIndex(2);
    //console.log(multiStepFormInstance.getActiveIndex());
  }
}]);

Is it possible to change step from controller method ?

By this I mean on my first step (i.e. launch-setup.html) there is 'Add' button on click of which I will add a record and want to navigate to next step if the record is successfully added, if not, then show the error message. For this I have written addStore() method inside the controller.
I want to know is it possible to render step 2 from this addStore method defined in controller?

from angular-multi-step-form.

troch avatar troch commented on June 19, 2024

Your code won't work, I am not sure what you want to do. But 'homeCtrl' cannot be a form step controller as well as the controller defining your steps. So you need two different controllers.

app.controller('stepCtrl', ['$scope', 'multiStepFormInstance', function ($scope, multiStepFormInstance) {
    $scope.addStore = function() {
         console.log('hello world');
         multiStepFormInstance.setActiveIndex(2);
         //console.log(multiStepFormInstance.getActiveIndex());
    };
});

app.controller('homeCtrl',['$scope', '$http', function($scope, $http) {
    $scope.storeSteps = [
                    {
                        templateUrl: '/app/modules/common-views/store/launch-setup.html',
                        hasForm: true,
                        controller: 'stepCtrl'
                    },
                    {
                        templateUrl: '/app/modules/common-views/store/step-one.html',
                        hasForm: true
                    },
                    {
                        templateUrl: '/app/modules/common-views/store/step-two.html',
                    },
                    {
                        templateUrl: '/app/modules/common-views/store/step-three.html',
                    },
                    {
                        templateUrl: '/app/modules/common-views/store/finish.html',
                    }

                ];
  }
}]);

from angular-multi-step-form.

rahul-cuelogic avatar rahul-cuelogic commented on June 19, 2024

Hi @troch ,

I created separate controllers as you mentioned in above comment, I am still the getting the same errror

Error: [$injector:unpr] Unknown provider: multiStepFormInstanceProvider <- multiStepFormInstance <- stepCtrl
http://errors.angularjs.org/1.4.5/$injector/unpr?p0=multiStepFormInstanceProvider%20%3C-%20multiStepFormInstance%20%3C-%20stepCtrl

from angular-multi-step-form.

rahul-cuelogic avatar rahul-cuelogic commented on June 19, 2024

Hi @troch ,
Do you have a sample example of injecting 'multiStepFormInstance' into controller? may be, I could refer that to see it in action and figure out what I am missing here

from angular-multi-step-form.

rahul-cuelogic avatar rahul-cuelogic commented on June 19, 2024

Thank you so much @troch ,

Are you certain you don't use 'stepCtrl' anywhere else in your app? The error you see is typical of the controller being instantiated outside the directive.

stepCtrl was getting instantiated from ng-controller directive in my HTML, I removed that it is working fine.

Again thanks a lot 👍

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.