mgonto / restangular

AngularJS service to handle Rest API Restful Resources properly and easily
MIT License
7.87k stars 840 forks source link

Error when injecting restangular with angular 1.6.4 #1470

Open andersonxf opened 7 years ago

andersonxf commented 7 years ago

I'm trying to use the rectangle but when injecting the same it gives the following error: Uncaught Error: [$injector:modulerr] Failed to instantiate module myapp due to: Error: [$injector:modulerr] Failed to instantiate module restangular due to: TypeError: Cannot read property 'isUndefined' of undefined at Object.Configurer.init (http://localhost:63342/teste-ecentry/bower_components/restangular/dist/restangular.js:42:29) at new (http://localhost:63342/teste-ecentry/bower_components/restangular/dist/restangular.js:812:16) at Object.instantiate (http://localhost:63342/teste-ecentry/bower_components/angular/angular.js:5018:14) at provider (http://localhost:63342/teste-ecentry/bower_components/angular/angular.js:4826:36) at Object.provider (http://localhost:63342/teste-ecentry/bower_components/angular/angular.js:4818:16) at runInvokeQueue (http://localhost:63342/teste-ecentry/bower_components/angular/angular.js:4890:35) at http://localhost:63342/teste-ecentry/bower_components/angular/angular.js:4899:11 at forEach (http://localhost:63342/teste-ecentry/bower_components/angular/angular.js:403:20) at loadModules (http://localhost:63342/teste-ecentry/bower_components/angular/angular.js:4880:5) at http://localhost:63342/teste-ecentry/bower_components/angular/angular.js:4898:40

The app.js file is like so: (function(){ 'use strict'; angular .module('myapp',['ngRoute', 'restangular','angularUtils.directives.dirPagination']); })()

my controller:

(function(){ 'use strict';

angular
.module('myapp')
.controller('contatoController', contatoController);

contatoController.$inject = ['contatoAPI','$scope','$location'];

function contatoController(contatoAPI,$scope, $location, Restangular ){

    $scope.getContato = function(){
        contatoAPI.getContato()
            .then(function(reponse){
                console.log(response)               
        },function (response) {
                console.log(response)

        });
    }       
}

})()

These are my dependencies: "dependencies": { "bootstrap": "~3.3.5", "angularUtils-pagination": "angular-utils-pagination#^0.11.1", "angular": "^1.6.4", "angular-route": "^1.6.4", "restangular": "^1.6.1" }

As it is the first time that I use this library, I would like the help of someone.

ghost commented 7 years ago

including the underscore js, which is a dependency of restangular, must resolve it

PapyElGringo commented 7 years ago

It's not, Any idea?

Edit:

You have to import Lodash before Restangular inside your index.html