Answer the question
In order to leave comments, you need to log in
How to do inversion of dependency injection in angular?
There is an awesome code: plnkr.co/edit/lnijKg?p=info that convinces me that the week has not been spent in vain.
But in this code there is one not very beautiful place:
angular.module('main', ['ui.router', 'foo'])
.config(function($stateProvider){
$stateProvider
.state('foo', { url: "/foo", 'abstract': true })
.state('foo.bar', { url: "/bar", directive: 'foo-bar' })
.state('foo.baz', { url: "/baz/:id", directive: 'foo-baz', closable: true })
;
})
angular.module('main', ['ui.router', 'foo', 'bar','baz'])
.config(function($stateProvider, fooStateConfs, barStateConfs, bazStateConfs){
function setup_states(modname, stateconfigs) {
$stateProvider.state(modname, { url: "/"+modname, abstract: true});
anguar.forEach(stateconfigs, function(name, params) { $stateProvider.state(modname+'.'+name, params }); });
}
setup_states('foo', 'fooStateConfigs');
setup_states('bar', 'barStateConfigs');
setup_states('baz', 'bazStateConfigs');
})
if( metaConf.enabled_mods.foo ) setup_states('foo', 'fooStateConfigs');
if( metaConf.enabled_mods.bar ) setup_states('bar', 'barStateConfigs');
angular.module('foo',['main'])
.config(function(mainTabsProvider) {
mainTabsProvider.tabs('foo');
mainTabsProvider.tab('foo.bar', params);
mainTabsProvider.tab('foo.baz', params);
});
angular.module('main',[])
.provider('mainTabs', function() { ... })
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question