Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)?

like image 734
Omar Avatar asked Dec 05 '13 18:12

Omar


1 Answers

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
like image 159
Omar Avatar answered Oct 21 '22 00:10

Omar