[Framework] Obey priority order for controllers et al

Support overriding of controllers between bundles.
This commit is contained in:
Victor Woeltjen 2015-09-17 17:51:06 -07:00
parent 19500c2704
commit 733a282f3f

View File

@ -52,6 +52,7 @@ define(
// named methods on Angular modules, which follow the normal // named methods on Angular modules, which follow the normal
// app.method(key, [ deps..., function ]) pattern. // app.method(key, [ deps..., function ]) pattern.
function customRegistrar(angularFunction) { function customRegistrar(angularFunction) {
var registered = {};
return function (extension, index) { return function (extension, index) {
var app = this.app, var app = this.app,
$log = this.$log, $log = this.$log,
@ -67,6 +68,14 @@ define(
", no key specified. ", ", no key specified. ",
JSON.stringify(extension) JSON.stringify(extension)
].join("")); ].join(""));
} else if (registered[key]) {
$log.debug([
"Already registered ",
angularFunction,
" with key ",
key,
"; skipping."
].join(""));
} else { } else {
$log.info([ $log.info([
"Registering ", "Registering ",
@ -74,6 +83,7 @@ define(
": ", ": ",
key key
].join("")); ].join(""));
registered[key] = true;
app[angularFunction]( app[angularFunction](
key, key,
dependencies.concat([extension]) dependencies.concat([extension])