Error: Failed to instantiate module restangular due to: '_' is undefined

一曲冷凌霜 提交于 2019-12-03 11:06:17

问题


When first using Restangular on a working website I got the following JavaScript error:

Failed to instantiate module restangular due to: '_' is undefined

What am I missing? What does it mean that '_' is undefined (in the Restangular module)?


回答1:


It's a simple oversight. The '_' (underscore) is a JavaScript utility library that Restangular uses and depends on. Include Lodash or Undrescore library before the AngularJS library (in your HTML):

<script src="lodash.js"></script>

or

<script src="underscore.js"></script>

PS: Double check the library script and path exist as referenced in your SCRIPT tag.

Additional readings:

  • Restangular Dependencies
  • Why Does Restangular Depend on lodash / underscore
  • Differences between lodash and underscore


来源:https://stackoverflow.com/questions/20408290/error-failed-to-instantiate-module-restangular-due-to-is-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!