-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
model not propagating between wzsteps #24
Comments
Same problem here. It seems that each step creates one different scope. |
Maybe it is because of the use of ng-repeat at this line https://github.com/mgonto/angular-wizard/blob/master/src/wizard.html#L4 , I am doing some digging here to find out... |
I am using ui-router |
As @prem-prakash said, each step creates one different scope. You can create the model in a parent scope of the steps, and gain access from each of the steps. I also needed to use a model at all steps and in my particular use case I created the model on the controller of the view that contain the wizard, then I could use it from each of the steps. |
Hi @cristianspinetta |
agreed. I'm new to angular and the whole scope thing has me quite confused. A simple example would go a long way here. |
yes, of course! If you need to have the model on a controller that wraps the wizard (it was my case): http://plnkr.co/edit/jYwwkUMc5IMUkR4zgB7P?p=preview Or maybe you want to manage the model only from the view: http://plnkr.co/edit/Nze2VbS31TyC3ZWdXWy0?p=preview For know more about the scopes, you can read this answer from stackoverflow: http://stackoverflow.com/questions/14049480/what-are-the-nuances-of-scope-prototypal-prototypical-inheritance-in-angularjs#14049482 |
Thanks so much. That's an excellent example and demonstrates clearly how to share the model between steps. Thanks for taking the time to post this. |
If you look at the source code of the step directive, you'll see it defines a scope, which automatically becomes a childscope, what you must do is not replace the reference of the parent scope value in the child scope, and Angular will navigate the scope tree to find it. |
@Igosuki maybe I'm not understanding well, you said that it's not necessary to reference the parent scope to create the model? could you make an example on plunker? |
@cristianspinetta +1. A plunkr example would be awesome |
Use a object, when you use a regular variable it will use the scope local to the step. If you use
and refer to it via |
Coming too late but, your problem is related to the basics of : if I replace the value of an object completely in Javascript, then I am changing its reference. |
closing due to inactivity, I will reopen if people still have questions |
in the following code fragment....
the model item groupName isn't available in the 2nd wzStep. I was expecting it to be populated with what was typed in the first step of the wizard. Any ideas?
The text was updated successfully, but these errors were encountered: