Let's say I have a module called App that introduces two other modules called factories and controllers:
var app = angular.module("app", ["factories", "controllers", "directives"]) .run(function ($rootScope, userFactory) { userFactory.property = "someKickstartValue"; });
The factories module contains all the plants:
var factories = angular.module("factories", []), factory = factories.factory("testFactory", { property: "someValue" });
And the controller module contains all the controllers:
var controllers = angular.module("controllers", ["factories"]), controller = controllers.controller("controller", function ($scope, testFactory) { console.log(testFactory.property); // Returns "Some Value" and not // "someKickstartValue" as expected. });
Actual question:
Why doesn't "someKickstartValue" apply to controllers? As far as I understand, a modular application has its own instance of testFactory, and module controllers have its own, so there can be no information shared between modules through factories. Is there a way, or have I made a mistake?
source share