0

I'm trying to make the simplest possible website setting, where I have an Angular.js app with single module depending on one external module (for example Restangular).

I don't know why, but I can not get it working. I'm getting get this kind of error:

Error: [$injector:unpr] http://errors.angularjs.org/1.2.17/$injector/unpr?p0=restangularProvider%20%3C-%20restangular

Actually, it doesn't matter that it's restangular - I've tried it with other modules and the result was analogical.

I have created a plunker that shows my problem: http://plnkr.co/edit/3ZUoDYtd4sVTT7nLpURi?p=preview

But there is not that much code - I will paste it here too.

In my index.html file I include angular.js, lodash.js (required by restangular), restangular.js and my application's script.js files with tags.

This is the body of my html:

<body ng-app="example" ng-controller="AppCtrl">
    <p>Take a look into console... Restangular can not get injected. What am I doing wrong?</p>
</body>

And this is the content of script.js:

var app = angular.module( 'example', ['restangular'])

app.controller('AppCtrl', ['$scope', 'restangular', function($scope, Restangular) {
    console.log(Restangular);
}]);

As a note - in the console I can do this:

angular.module('restangular')

but, this does not work:

angular.injector(["ng"]).get('restangular')

It seems that I'm missing something basic about Angular.js. Help will be appreciated...

0

1 Answer 1

1

Could it be this?

app.controller('AppCtrl', ['$scope', 'Restangular', function($scope, Restangular) {

Restangular hast to be written with a capital R You wrote

app.controller('AppCtrl', ['$scope', 'restangular', function($scope, Restangular) {

At least now I see in the console

URL visited /edit/3ZUoDYtd4sVTT7nLpURi
editor-0.7.30.js 
Object { configuration={...}, requestParams={...}, defaultHeaders={...}, more...}
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, it was indeed this issue. I find it a bit misleading that while declaring my module I have to declare this dependency like this: ['Restangular'], but than later in a controller in this way: ['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.