Comments (23)
It is in fact triggered, nevermind :)
from oclazyload.
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?
from oclazyload.
yes it should, do you have an example where it is not the case ?
from oclazyload.
http://ngproject.herokuapp.com/#/notes
notesModules.js
if debug, you will see only .run is triggered
app.js is main app module
from oclazyload.
Hmm you're right, there is something fishy here, I'll check it out tomorrow, thanks
from oclazyload.
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.
from oclazyload.
Thanks, great, the lib is fantastic, together with uiRouter makes perfect couple :-)
from oclazyload.
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,
module,config()
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
from oclazyload.
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.
This part of the code is to know if the module config block has been invoked. Only modules have a config block that's why the module name is a sufficient distinction.
from oclazyload.
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...
from oclazyload.
That's why there is the parameter reconfig
:)
from oclazyload.
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
from oclazyload.
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 name
property when you load non-angular files, and if you're calling the module as a dependency of itself it is an endless recursive behavior.
But if you remove this, it should work and the config should be invoked once (with the version 0.3.4 of the lib). Isn't it ?
from oclazyload.
no, still called only once, yes 0.3.4
from oclazyload.
Yes, that's how it is supposed to be.
the config should be invoked once (with the version 0.3.4 of the lib)
Use reconfig:true
if you want to call it each time you lazy load it.
from oclazyload.
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....)
from oclazyload.
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 ?
from oclazyload.
yes then it works
from oclazyload.
Ok ! Then yes I did not understand the problem, thanks !
I'll see how to fix that :)
from oclazyload.
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......
from oclazyload.
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:
- defined multiple times (only the first 1 would be invoked)
- defined with an auto injected module: ['...', function() {}]
- defined after another component: angular.module().controler().config()
from oclazyload.
great, gonna test now
from oclazyload.
Works great, thanks a lot.
from oclazyload.
Related Issues (20)
- Thank you HOT 1
- Added new link to ADVANCED USAGE section HOT 2
- Lazy-load MonacoEditor, which has an AMD loader
- AngularJS: Broken lazy loaded modules on state removal HOT 1
- [Web pack with ocLazyLoad] Fails to load the controller and template
- How it should work with unit-tests? HOT 2
- problem in angular 1.7.2 HOT 3
- Module's config loaded via ocLazyLoad is not getting called HOT 2
- Confused to attach dynamic controller into template view
- Can't use within app config HOT 1
- URL Parameters stay empties HOT 2
- Error: Load timeout for modules: ../d3.v2.js
- Lazyloading controllers - Not working HOT 1
- serie = true not working HOT 1
- Is the project dead? HOT 2
- Examples don't run
- How to lazyload typescirpt modules with oclazyload in AndularJs 1.5+ and ui-router?
- ocLazyLoad with Karma and Webpack HOT 2
- High Security issue XSS on ocLazyLoad 0.5.2 at 235 line HOT 1
- Change name or location of lazy chunks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oclazyload.