Errors when adding to the project: `Error: $ injector: modulerr`

When adding Restangular to the project, it throws sn error [Error: $injector:modulerr]

. I'm pretty sure this error isn't thrown by one of my own modules. I followed the setup docs and I log out of their CDN. If Restangular is removed as a dependency, it works.

Reproduced below:

JS:

angular.module('app', ['restangular'])
.controller('Main', function(){
    this.msg = 'Hello World'
})

      

HTML:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/restangular/1.3.1/restangular.js"></script>

<main ng-app="app" ng-controller="Main as vm">
  <h1>{{vm.msg}}</h1>
</main>

      

Reproduced in codepen .

+3


source to share


2 answers


So you are missing the _.js dependency. I was able to update CodePen and did your code

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/restangular/1.3.1/restangular.js"></script>
<main ng-app="app" ng-controller="Main as vm">
    <h1>{{vm.msg}}</h1>
</main>

      



just so there is no magic here plunker http://plnkr.co/edit/OvUefl8x0H6dvZs2B0ls?p=preview

+6


source


Restangular depends on Angular and Lodash (or Underscore).



Watch it

+2


source







All Articles