mortsahl
mortsahl

Reputation: 602

AngularJS 1.2.15 and Restangular 1.3.1 problems

I must be missing something very basic but I can't get Restangular to load. My steps ...

  1. Scaffold a new project with Yeoman
  2. Insert includes for Lodash and Restangular
  3. Inject restangular into my module.
  4. grunt test

This is the result ...

Error: [$injector:modulerr] Failed to instantiate module fooApp due to:
Error: [$injector:modulerr] Failed to instantiate module restangular due to:
Error: [$injector:nomod] Module 'restangular' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

Here are my includes ...

<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/lodash/dist/lodash.js">
<script src="bower_components/restangular/dist/restangular.js">

Yes, they are in my bower_components directory.

My module definition is ...

angular.module('fooApp', [ 'ngResource', 'restangular' ]);

Any help would be appreciated

Upvotes: 0

Views: 2956

Answers (2)

mortsahl
mortsahl

Reputation: 602

Thanks to Marc Kline's help I finally got things working. Here's what I had to do:

yo angular foo
bower install lodash --save
bower install restangular --save
grunt bowerInstall
npm install karma-jasmine --save-dev
npm install karma-chrome-launcher --save-dev
npm install

Upvotes: 1

Alex H
Alex H

Reputation: 839

I had a similar issue to this, and the problem was due to the fact that I hasn't added the Lodash and Rectangular JS assets to my Karma test config.

Adding lodash.compat.min.js and restangular.min.js to the files array in karma.conf.js made my tests run correctly.

Upvotes: 0

Related Questions