Error: [$injector:unpr] Unknown provider: RestangularProvider <- Restangular <- ctrlAG

1.5k views Asked by At

I have one app:

app.js:

angular.module('AngApp', [
        'angularGrid'
    ]);

My own restangular service.js:

var app = angular.module('AngApp'); 
app.factory('restService', ['Restangular', function (Restangular) {
        // make use of Restangular
    }
]);

and controller.js:

var app = angular.module('AngApp');
app.controller('ctrlAG', ['$scope',  '$http', '$log', '$mdDialog', 
'Restangular',function ($scope,$http, $log, $mdDialog, Restangular) {
        // make use of other modules and Restservice

    }
]);

html is:

<script type="text/javascript" src="ng/app.js"></script>
<script type="text/javascript" src="ng/restangular.js"></script>
<script type="text/javascript" src="ng/restService.js"></script>
<script type="text/javascript" src="ng/ctrlAG.js"></script>
<script type="text/javascript" src="ng/ctrlMetadata.js"></script>

angular 1.3.6 , restangular (latest).

What is the reason that i take this error? I Have checked the commonly taken mistakes from here but non of them exists.

2

There are 2 answers

0
Anik Islam Abhi On BEST ANSWER

You didn't inject module of Restangular service.

Try like this

angular.module('AngApp', ['angularGrid','restangular']);
0
TrieuH On

It seem you also forget add either Lodash or underscore before. Because Restangular module depend on one of them. So in order to load Restangular module you have to add reference to Lodash or Underscore library,

Hope this help