-
Notifications
You must be signed in to change notification settings - Fork 461
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
Can it be injected into another provider? #70
Comments
Just inject it in your app and on the closure. app.module('yourMod', ['ngStorage']);
app.provider('item', function($localStorage) {}); |
Can also be done with more explicit dependency injection app.module('yourMod', ['ngStorage']);
app.provider('item', ['$localStorage', function($localStorage) {}]); |
Just curiosity, what is the main advantage/difference of injecting it the way you proposed with an array @egilkh? |
Mainly I think it's useful for minify/uglify tasks that try to mangle your parameters. Another thing you can do is "alias" the name of the injection. Example: app.provider('item', ['$localStorage', function(ls) {}]); Personally I like it more because it's just more verbose and there is no guesswork when reading the code. For reference: https://docs.angularjs.org/guide/di |
Makes lot of sense. Thank you for the note and the reference. So useful. |
app.provider('Item', ['$localStorage',
function($localStorage) {
................
}])
seems not working, cannot find the $localStorage provider
The text was updated successfully, but these errors were encountered: