Comments (14)
Same problem here. It seems that each step creates one different scope.
from angular-wizard.
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...
from angular-wizard.
I am using ui-router
from angular-wizard.
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.
from angular-wizard.
Hi @cristianspinetta
If it is not asking too much, could you give a simple example of how you did this?
I believe it is important to add an example like this to README.md.
from angular-wizard.
agreed. I'm new to angular and the whole scope thing has me quite confused. A simple example would go a long way here.
from angular-wizard.
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
from angular-wizard.
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.
from angular-wizard.
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.
However, it is better to use a service to share data between directives than a parent controller, if you need generic behavior just pass the name of the provider in the attributes and get it manually through $injector.get
from angular-wizard.
@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?
from angular-wizard.
@cristianspinetta +1. A plunkr example would be awesome
from angular-wizard.
Use a object, when you use a regular variable it will use the scope local to the step. If you use
$scope.selected = {
groupName: '...'
}
and refer to it via data-ng-model="selected.groupName"
it will work.
from angular-wizard.
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.
http://jsfiddle.net/w0boyfw7/2/
from angular-wizard.
closing due to inactivity, I will reopen if people still have questions
from angular-wizard.
Related Issues (20)
- wizard().goTo() not behaving as expected HOT 3
- setEditMode is not a function HOT 2
- error HOT 1
- ReferenceError on "canexit="exitValidation"" [Fix included] HOT 3
- Angular 4 support? HOT 2
- Can't reference a controller's function from template HOT 2
- Issue when add the canenter feature. HOT 3
- wz-data and canenter are being called multiple times
- removing a step fails if it index 0
- Why from data from first step is lost when a user tries to visit another step?
- on removing wz-step anomaly
- Wizard Handler goTo issue HOT 1
- Can i use this in angular 2 ? HOT 2
- How to make the navigation bar Non clickable? HOT 1
- Disabling steps dynamically
- How to disable navigation in the toolbar HOT 3
- JS Error: _ is not defined
- RTL problem
- back to current step if back to other completed steps
- Input values not sending to PHP
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-wizard.