How to change the list of currently nested dependencies in angular

I am trying to create a modular angular app with the ability to insert new modules into an inner panel or remove currently added ones.

  • How to get list of added dependencies in angular application?
  • how can i change them? (insert, delete).
+3


source to share


1 answer


The list of module dependencies is in the requires

module property.

eg.

var app = angular.module("app", ["dep1"]);
console.log(app.requires);

      



You can try adding a dependency to this list at runtime. This simple example worked for me.

(function() {
    "use strict";
    var app1 = angular.module("ag.test", []);
    app1.factory("agTestFactory", [function() {
        return {
            hello: function() {
                console.log("hello");
            }
        };
    }]);
    var app = angular.module("app", ["app.configurations", "app.routes"]);
    app.requires[app.requires.length] = "ag.test";
    app.run(["agTestFactory", function(tf) {
        tf.hello();
    }]);
})();

      

If that doesn't solve your problem, when can you take a look at this thread. https://groups.google.com/forum/#!topic/angular/w0ZEBz02l8s

+1


source







All Articles