最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Restangular - _.contains() is not a function - Stack Overflow

programmeradmin1浏览0评论

If you have recently updated restangular through bower it will have installed the latest lodash - the new 4.0. However this is a problem as restangular/angular now throws the error - "_.contains() is not a function."

How do you solve?

If you have recently updated restangular through bower it will have installed the latest lodash - the new 4.0. However this is a problem as restangular/angular now throws the error - "_.contains() is not a function."

How do you solve?

Share Improve this question edited Jan 21, 2016 at 13:17 Sten Muchow asked Jan 21, 2016 at 11:32 Sten MuchowSten Muchow 6,7014 gold badges37 silver badges46 bronze badges 0
Add a comment  | 

3 Answers 3

Reset to default 8

The solution is very simple - you need to tell restangular to use a lower version than the newest lodash - 3.10.0

Through bower.json

 "lodash": "~3.10.0"

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

Couldn't you put this in app.js

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

If you have not specified the entry for lodash explicitly and this gets installs as a dependency of restangular, you can uninstall both of them and reinstall lodash (3.10.1) to fix the issue.

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

This way you would not need an entry into the bower.json file.

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

发布评论

评论列表(0)

  1. 暂无评论