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 use with angular? #285
Comments
@chovy Bit late to this party, but I noticed this issue while looking for a solution to a different one! Hopefully you've found a solution by now, but in case anyone else needs this in future, or I forget myself: One possible solution that follows angular idioms, for the most part: In the app I'm currently working on (much the same setup - As such, I've imported lodash like so:
So extending that concept, if you want to use underscore.string as a mixin to lodash (instead of as its own injectable service), you can do the mixin when you set up the lodash service. You do this in much the same way you would in a non-angular project (see https://github.com/epeli/underscore.string/blob/master/README.markdown#string-functions) So we'd rewrite the definition of the lodash module above as follows:
So now the service in my app in the example above can use string functions right off the underscore dependency, so for example, extending the above:
Related issue you might run intoImproper bower.json on underscore.stringWhile the current HEAD of underscore.string includes a bower.json - the latest tagged release DOESN'T. As such, the underscore.string you'll find when you do I ran into a problem where the setup created by The solution to that is to add the following to your project's
Karma doesn't like you deleting things from windowOnly an issue if you use karma, and you should The way karma testing operates - the new modules you defined above are re-instantiated every time a karma spec runs, but the scripts are injected into the page only once. This is a problem - we deleted I got around this by changing the pattern for nabbing stuff off window slightly. I still don't want $window polluted, so I added a
|
Is there a way to use this library with angular 2 ? |
I"m currently loading lodash using yeoman includes like this:
How would I include your library as a mixin such that I can do
_.capitalize()
?The text was updated successfully, but these errors were encountered: