Git Product home page Git Product logo

Comments (14)

prem-prakash avatar prem-prakash commented on May 14, 2024

Same problem here. It seems that each step creates one different scope.

from angular-wizard.

prem-prakash avatar prem-prakash commented on May 14, 2024

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.

prem-prakash avatar prem-prakash commented on May 14, 2024

I am using ui-router

from angular-wizard.

cspinetta avatar cspinetta commented on May 14, 2024

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.

prem-prakash avatar prem-prakash commented on May 14, 2024

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.

 avatar commented on May 14, 2024

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.

cspinetta avatar cspinetta commented on May 14, 2024

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.

 avatar commented on May 14, 2024

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.

Igosuki avatar Igosuki commented on May 14, 2024

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.

cspinetta avatar cspinetta commented on May 14, 2024

@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.

mgonto avatar mgonto commented on May 14, 2024

@cristianspinetta +1. A plunkr example would be awesome

from angular-wizard.

leeopencare avatar leeopencare commented on May 14, 2024

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.

Igosuki avatar Igosuki commented on May 14, 2024

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.

jacobscarter avatar jacobscarter commented on May 14, 2024

closing due to inactivity, I will reopen if people still have questions

from angular-wizard.

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.