Restangular - _.contains () is not a function

If you recently upgraded the restoring system using bower, it will install the latest version of lodash - the new version 4.0. However, this is a problem because restangular / angular now throws an error - "_.contains () is not a function."

How do you decide?

+5
source share
3 answers

The solution is very simple - you need to say that restangular uses a lower version than the latest lodash - 3.10.0

Via bower.json

"lodash": "~3.10.0" 

https://github.com/mgonto/restangular/issues/1298

+7
source

If you did not specify an entry for lodash explicitly, and this gets the settings as a restangular , you can remove both of them and reinstall lodash (3.10.1) to fix the problem.

 bower uninstall restangular bower uninstall lodash bower install --save lodash#3.10.1 bower install --save restangular 

This way you do not need to write to the bower.json file.

Source: https://github.com/mgonto/restangular/issues/1294

+4
source

Could you put this in app.js

 // If Restangular ever updates to lodash 4.0 remove this. _.contains = _.includes 
+3
source

Source: https://habr.com/ru/post/1241126/


All Articles