-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The module config is not triggered #5
Comments
It is in fact triggered, nevermind :) |
actually it is triggered only with reconfig:true. Should the config be triggered for the first time module has been loaded, regardless of reconfig parameter? |
yes it should, do you have an example where it is not the case ? |
http://ngproject.herokuapp.com/#/notes app.js is main app module |
Hmm you're right, there is something fishy here, I'll check it out tomorrow, thanks |
Ok thanks for the report, there was a stupid coding mistake in my code (I really need to finish those unit tests), it's fixed now, I should publish a new version soon. |
Thanks, great, the lib is fantastic, together with uiRouter makes perfect couple :-) |
Hi, i think it is not working, problem could be here: for(i = 0, len = queue.length; i < len; i++) {
args = queue[i];
if(angular.isArray(args)) {
if(providers.hasOwnProperty(args[0])) {
provider = providers[args[0]];
} else {
throw new Error('unsupported provider ' + args[0]);
}
var invoked = regConfigs.indexOf(moduleName);
if(registerInvokeList(args[2][0]) && (args[1] !== 'invoke' || (args[1] === 'invoke' && invoked === -1)) || (args[1] === 'invoke' && reconfig)) {
if(invoked === -1) {
regConfigs.push(moduleName);
}
provider[args[1]].apply(provider, args[2]);
}
}
} regConfigs.push(moduleName); it can be called more times with the same moduleName, moduel,controller, .directive functions, i think you should save in the regConfigs array more specific token, like module name + function.toString that invoked the call? try load module that calls .controller and .config methods |
If you want to call it more than one time, you need to use the parameter reconfig:true. There are many times where you don't want the config function to be called multiple times, that's why it has to be voluntary. |
sure, but in many times you declare some service/provider as module.provider() and then configure it in .config() method, and still need to call these for the first time... |
That's why there is the parameter |
sou you cannot call these on lazy loaded module? angular.module("notesModule", [
"ui.router",
{
name: 'notesModule',
files: [
'modules/css/styles.css'
]
}
])
.controller("NotesController", ["$scope", NotesController])
.config(function($provide){
alert("notesModule config ");
//$provide.controller("NotesController", ["$scope", NotesController]);
}) only .controller is called |
It should be: angular.module("notesModule", [
"ui.router",
{
files: [
'modules/css/styles.css'
]
}
])
.controller("NotesController", ["$scope", NotesController])
.config(function($provide){
alert("notesModule config ");
//$provide.controller("NotesController", ["$scope", NotesController]);
}) You don't need to specify the |
no, still called only once, yes 0.3.4 |
Yes, that's how it is supposed to be.
Use |
I dont thing you understand what I mean, .config is not called even for the first time, if you call .controller before, (and assume same it is with service, constant, value....) |
And if your code was: angular.module("notesModule", [
"ui.router",
{
files: [
'modules/css/styles.css'
]
}
])
.config(function($provide){
alert("notesModule config ");
//$provide.controller("NotesController", ["$scope", NotesController]);
})
.controller("NotesController", ["$scope", NotesController]) It would work ? Because the config is before the controller ? |
yes then it works |
Ok ! Then yes I did not understand the problem, thanks ! |
anf if I add: .controller("NotesController", ["$scope", NotesController])
.factory("NotesService", function($q){
alert("NotesService");
return {
name:"NotesService"
}
}) after .config, these are not called, invokeQueue has been called with .config...... |
Ok I fixed a bunch of bugs and released 0.3.5, thanks for your persistence because I found multiple cases where config would not be called ! The config block would not be called if:
|
great, gonna test now |
Works great, thanks a lot. |
It seems that the config part of a module lazy loaded is not triggered:
I should check out if this is actually the case, and if so fix it
The text was updated successfully, but these errors were encountered: