troch / angular-multi-step-form

An angular module for creating multi step forms / wizards

Home Page:http://troch.github.io/angular-multi-step-form

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

form is not accessible in controllers

bagwanpankaj opened this issue · comments

When steps are used with templateUrl, form is not accessible in controller even not in multi-step-container

Can you give me an example to reproduce? Thanks.

I put up a bare minimum angular app here. MultiStep form can be found at /#/about. The issue is as follows

1.) angular form object is available within the template it is defined (step_1.html and step_2.html templates)
2.) angular form object is not available in wrapper template that defines <multi-step-container steps="steps"> (defined in about.html)
3.) angular form object is not available in AboutCtrl. Since it can not pased as well via nextStep function, see point#2

I think this is expected. The form object (from Angular's <form> directive) will be added to the scope of the step it is in. Therefore you cannot access it from either the scope of the multi-step form directive or your surrounding scope (used by AboutCtrl).

What you can do is something similar to this: https://github.com/troch/angular-multi-step-form/blob/master/src/directives/form-step-validity.js. With a custom directive, you can grab your form instance (formCtrl) and pass it to another controller or factory.

Got that. Thanks

One another thing you can do, depending on your use case, is to have a surrounding <form> rather than forms in each step.