Giter VIP home page Giter VIP logo

Comments (2)

ocombe avatar ocombe commented on May 30, 2024

Hi. It is not a bug (it's a feature!).
You can use the same controller for different parts of your application, but the $scope injected by angular won't be the same, you will have 2 distinct instances of the controller.

In this case, your first controller is using a local $scope, and the controller in the modal is using a new scope that is generated for the modal only (and isolated scope).

If you want to share variables from another scope, you will need to use the init parameter when you open the modal. All init variables will extend the modal scope (and be in the $init parameter of the controller as well), it should then work as you expect.

You could also use $rootScope that is unique everywhere in your application because it is the root of all scopes.

from ocmodal.

morganwildermuth avatar morganwildermuth commented on May 30, 2024

Ah! I see; I was assuming that the purpose of referencing a ctrl was to connect to the scoped items within it, so I assumed it would not create a new instance of the controller. As for $init, that makes sense. I followed the outline in the ocModal documentation, but when I tried to inject the $init dependency into my controller I ran into an 'unknown provider' issue. For now I'm just relying on $rootScope, but thank you for the thorough explanation!

from ocmodal.

Related Issues (18)

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.