I'm getting this error: Uncaught ReferenceError: _ is not defined from restangular
when trying to use Restangular.
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
<script type="text/javascript" src="http://cdn.jsdelivr.net/restangular/latest/restangular.min.js"></script>
<script src="app.js"></script>
<script src="controllers.js"></script>
app.js
var contactManager = angular.module('contactManager', ['restangular'])
contactManager.config(function(RestangularProvider){
RestangularProvider.setBaseUrl('/api/');
})
Answer: Execute Code after jQuery Library has Loaded The most common reason behind the error "Uncaught ReferenceError: $ is not defined" is executing the jQuery code before the jQuery library file has loaded. Therefore make sure that you're executing the jQuery code only after jQuery library file has finished loading.
The Javascript ReferenceError occurs when referencing a variable that does not exist or has not yet been initialized in the current scope.
you need to add a script reference to underscore, as is a dependency
<script src="https://cdn of underscore"></script>
restangular
requires underscore/lodash` to work. Just put this dependancy before your restangular script. Also read this comment on github.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With