Skip to content
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

ng-lodash with restangular #1303

Open
steel119 opened this issue Jan 20, 2016 · 9 comments
Open

ng-lodash with restangular #1303

steel119 opened this issue Jan 20, 2016 · 9 comments

Comments

@steel119
Copy link

Hi,

Is it possible to use restangular with ngLodash. I tried using it but its giving me an error?
Uncaught Error: [$injector:modulerr]

Thanks!!

@steel119
Copy link
Author

Did anyone got a chance to look at this?

@bz123
Copy link

bz123 commented Jan 21, 2016

restangular uses lodash by default, but it uses lodash 3.10 and not the latest one.

Latest version of lodash has changed around a few things such as _.contains is now _.includes and has other things applied such as _.slice etc.

I feel like restangular is discontinued somehow the repo hasn't been updated since June.

btw here is restangulars bower file under dependencies you can clearly see that restangular requires lodash in order to go ahead.

burnpiro pushed a commit to burnpiro/angular-blog that referenced this issue Jan 21, 2016
@dalgard
Copy link

dalgard commented Jan 22, 2016

+1

Restangular should specify lodash correctly (in accordance with SemVer) in its package.json file.

@steel119
Copy link
Author

My question is not about the latest issue that we are facing because of lodash upgrade to 4.0.0.
We have an angularized version of lodash known as ngLodash. I tried using restangular using ngLodash but i am facing error while doing so. Is there a way to run restangular using ngLodash?

@daviesgeek
Copy link
Collaborator

@dalgard lodash is specified in the package.json: https://github.com/mgonto/restangular/blob/master/package.json#L32

@daviesgeek
Copy link
Collaborator

@steel119 I don't know how exactly ngLodash would work with Restangular. Restangular references Lodash directly on window, but there's been added support for for modules, so maybe there's a way to hook into that?
There's also been some talk of removing lodash.
Anyhow, this seems like a reasonable thing to support, so I'd love to hear your thoughts on it/see a PR for it.

@codeuniquely
Copy link

If there is a specific need for a particular version of lodash then the package.json file should have that expected version in the file.

ALSO (important)
If the project has a requirement that the lodash exists before it is loaded then it should require that dependency, so that it actually works and correctly loads its own dependencies in such a way as not to cause errors.

var _ = require('loadash'); somewhere 

right now - requiring restangular just generates the following error:

angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module MyApp due to:
Error: [$injector:modulerr] Failed to instantiate module restangular due to:
ReferenceError: _ is not defined
    at Object.a.init (webpack:///./~/restangular/dist/restangular.min.js?:6:716)
    at new eval (webpack:///./~/restangular/dist/restangular.min.js?:6:10642)
    at Object.instantiate (webpack:///./~/angular/angular.js?:4733:14)
    at provider (webpack:///./~/angular/angular.js?:4547:36)
    at Object.eval [as provider] (webpack:///./~/angular/angular.js?:4539:16)
    at runInvokeQueue (webpack:///./~/angular/angular.js?:4611:35)
    at eval (webpack:///./~/angular/angular.js?:4619:11)
    at forEach (webpack:///./~/angular/angular.js?:321:20)
    at loadModules (webpack:///./~/angular/angular.js?:4601:5)
    at eval (webpack:///./~/angular/angular.js?:4618:40)
http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=restangular&p1=Refe…t%20eval%20(webpack%3A%2F%2F%2F.%2F~%2Fangular%2Fangular.js%3F%3A4618%3A40)
    at eval (webpack:///./~/angular/angular.js?:68:12)
    at eval (webpack:///./~/angular/angular.js?:4640:15)
    at forEach (webpack:///./~/angular/angular.js?:321:20)
    at loadModules (webpack:///./~/angular/angular.js?:4601:5)
    at eval (webpack:///./~/angular/angular.js?:4618:40)
    at forEach (webpack:///./~/angular/angular.js?:321:20)
    at loadModules (webpack:///./~/angular/angular.js?:4601:5)
    at createInjector (webpack:///./~/angular/angular.js?:4523:19)
    at doBootstrap (webpack:///./~/angular/angular.js?:1758:20)
    at bootstrap (webpack:///./~/angular/angular.js?:1779:12)
http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=wcy&p1=Error%3A%20%…ootstrap%20(webpack%3A%2F%2F%2F.%2F~%2Fangular%2Fangular.js%3F%3A1779%3A12)

@daviesgeek
Copy link
Collaborator

If there is a specific need for a particular version of lodash then the package.json file should have that expected version in the file.

Like this?

If the project has a requirement that the lodash exists before it is loaded then it should require that dependency, so that it actually works and correctly loads its own dependencies in such a way as not to cause errors.

Like this?

You might be using an older version of Restangular. There are a couple commits to master that aren't in a release that fix this. See also #1397. Try using the version of Restangular on master for right now until 1.5.3 is released.

@mackelito
Copy link

Should not restangular have lodash injected as a factory or such?
I want to make a angular wrapper factory around lodash as explained here http://www.jvandemo.com/how-to-properly-integrate-non-angularjs-libraries-in-your-angularjs-application/

But it will break due to restangulars dep on lodash "$window._"

Any ways to fix that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants