-
Notifications
You must be signed in to change notification settings - Fork 509
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
How to dependency injection using ocLazyLoad #353
Comments
Hi! angular.module('myApp', [ 'ui.router', 'oc.lazyLoad' ]); If you are using ui.router: angular.module('myApp').config(
['$stateProvider', '$urlRouterProvider',
function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/access/signin');
$stateProvider
.state('chart', {
url: '/chart-view',
templateUrl: 'path/to/your/view',
resolve: {
store: function ($ocLazyLoad) {
return $ocLazyLoad.load(
{
serie: true,
name: "chart.js",
files: [
"path/to/Chart.min.js",
"path/to/anguar-chart.min.js",
]
}
);
}
}
});
}
]
); |
Thanks 👍 very useful, I also added an answer on Stackoverflow for users who are not using |
cool! so you can close the issue! |
It actually works .... Hey can you explain me how it is injecting dependency ... TIA ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This question asked on Stackoverflow but no one answered that, I was curious to know the answer, and I posted that here:
I'm using ocLazyLoad and I have some external angular libraries (Like Chart.js and pascalprecht.translate) and I need to lazy load them in some routes, as you know, for the common angular module dependency injection should be like:
Now, I just need to lazy loading pascalprecht.translate in one of my controllers and also lazy loading chart.js, in another controller, but I still need to add inject them to myApp module but I don't know how to inject and I do not use $stateProvider
I tried this my controller that I needed chart.js:
But I got this error:
The text was updated successfully, but these errors were encountered: