Carlos Bergen
Carlos Bergen

Reputation: 813

Uncaught ReferenceError: _ is not defined from restangular

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/');
})

Upvotes: 16

Views: 24969

Answers (4)

Brajesh
Brajesh

Reputation: 1555

Might be, you should need to add following .js files:-

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular-resource.js">
</script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular-route.js">
</script> 
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/restangular/1.5.1/restangular.js">
</script>

Upvotes: 0

Sumit Gupta
Sumit Gupta

Reputation: 785

You need to add a reference of underscore.js in your html file. You can use following cdn path:

<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>

Upvotes: 10

Rayweb_on
Rayweb_on

Reputation: 3727

you need to add a script reference to underscore, as is a dependency

 <script src="https://cdn of underscore"></script>

Upvotes: 18

Pono
Pono

Reputation: 11786

restangular requires underscore/lodash` to work. Just put this dependancy before your restangular script. Also read this comment on github.

Upvotes: 11

Related Questions