1

I have this angular app and controller modules defined as follows:

var myTasks = angular.module('myTasks', [
                                          'ngRoute',
                                          'myTasksControllers'
                                        ]);
var myTasksControllers = angular.module('myTasksControllers',[]);

I also have:

    <script src="js/lib/angular.min.js"></script>
    <script src="js/lib/angular-route.min.js"></script>
    <script src="js/lib/lodash.min.js"></script>
    <script src="js/lib/restangular.min.js"></script>
    <script src="js/app.js"></script>

And I am trying to inject rectangular into my controller like so:

myTasksControllers.controller('ProjectsController', ['$scope','rectangular',
  function ($scope, Rectangular) {
    ...
    ...
  }
]);

But it keeps telling module not defined or something. To be precise:

Error: [$injector:unpr] http://errors.angularjs.org/1.2.3/$injector/unpr?p0=rectangularProvider%20%3C-%20rectangular
    at Error (<anonymous>)

Rectangular: https://github.com/mgonto/restangular#how-do-i-add-this-to-my-project

2
  • 2
    Well, "rectangular" is not the same as "restangular". Commented Dec 5, 2013 at 11:18
  • Omg. Im sorry I didnt notice that! Commented Dec 5, 2013 at 14:00

1 Answer 1

4

You have to inject restangular module into your myTasks module first. Like this:

var myTasks = angular.module('myTasks', [
                                      'restangular',
                                      'ngRoute',
                                      'myTasksControllers'
                                    ]);

Than, you have to inject Restangular into your controller:

myTasksControllers.controller('ProjectsController', ['$scope','Restangular',
  function ($scope, Restangular) {
    ...
    ...
  }
]);

P.S.: Note that you have spelled it "rectangular" in your question :)

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

3 Comments

Thank you!! it worked. Thanks a lot. ANd sorry for the typo. :)
I had a similar issue and the I solved it by including a reference to lodash in my index.html file.
@AdamLabi Yes, because Lodash is a dependency of 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.