0

In my app I need an API REST connection with server so I've decided to use this one: https://github.com/mgonto/restangular but when I try to load it into my module:

var app = angular.module('onboarding',['ngRoute','ngSanitize','ngStorage','restangular']);

I get this error:

Failed to instantiate module restangular due to:
Error: [$injector:nomod] 
http://errors.angularjs.org/1.6.2/$injector/nomod?p0=rest...
at http://localhost:3000/scripts/angular.min.js:6:425
at http://localhost:3000/scripts/angular.min.js:25:399
at b (http://localhost:3000/scripts/angular.min.js:24:439)
at http://localhost:3000/scripts/angular.min.js:25:173
at http://localhost:3000/scripts/angular.min.js:41:117
at q (http://localhost:3000/scripts/angular.min.js:7:351)
at g (http://localhost:3000/scripts/angular.min.js:40:476)
at http://localhost:3000/scripts/angular.min.js:41:134
at q (http://localhost:3000/scripts/angular.min.js:7:351)
at g (http://localhost:3000/scripts/angular.min.js:40:476

In documentation on github it is written that only versions between 1.0.X and 1.5.X are supported. Since I use version 1.6.2 that could be the problem. But when I've changed my version to 1.5.9 again I get exactly the same error.

Is that bug with my code or with this library? Has anyone had similar error with angular version coincidence?

5
  • Could you please provide some code snippet. And please make sure that you have added the required js file for restangular. Also, do include it as a dependency in the main module. Commented Apr 13, 2017 at 11:33
  • Sure! I've edidted my code. Commented Apr 13, 2017 at 11:36
  • restangular should work fine in 1.6.2; as to the error you are getting, that usually happens when your scripts aren't included in the HTML or they are in the wrong order. you can use angular.js instead of angular.min.js to get a more descriptive error message. Commented Apr 13, 2017 at 11:42
  • I've included each file into my HTML code (no errors about that). This is my order of scripts: 1. jQuery 2. jQuery-UI 3.Boostrap 4.Angular 5.ngRoute 6.restangular 7.ngStorage 8. angular-sanitize Commented Apr 13, 2017 at 11:54
  • Now I've found something strange: after loading restangular module on my command console I get error from : jquery-3.1.1.min.js:2 not from restangular. What jQuery has to do with that? Commented Apr 13, 2017 at 12:00

2 Answers 2

2

I think this is the cause: That Restangular depends on angular, angular-resource and underscore. If you don't have Underscore.js in your references, add it and test it once more.

This is not explicitly mentioned in their documentation. You can also use Lodash for this purpose.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes. Now it works properly. My bad. Thank you for solving my problem!
1

Either restangular is not installed in your project or you haven't imported restangular.

Did you import them in your index page ?

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

1 Comment

Yes I did. Also now I see that this error come from jquery-3.1.1.min.js:2. So maybe there is a problem with coincidence between jQuery and restangular?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.