What warning is this on the console using AngularJS?

1

I'm trying to run a simple code with angular and this warning appears on the console:

  

Uncaught Error: [$ injector: modulerr] link $ injector / modulerr? p0 = app & p1 = Error % 3A% 20% ... angular.js: 38

Here's my app.js file:

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

My controller:

app.controller('appController', function ($scope, $http, $stateParams){

$scope.pegaCep = function (data) {
    $http.get("php/pegaCep.php?cep="+$stateParams.cep).success(function (data){
        console.log(data);
    });
 }

});

Yes, the warning speaks about the wrong injection of the controller, but how wrong?

    
asked by anonymous 20.01.2016 / 18:58

1 answer

3

You are using a minuted version of AngularJS, so errors are not being displayed in an extended format.

On a quick review, I think you're using the $stateParams injector, which belongs to the UI library router Angular UI . However, your application statement is not including it.

To solve the problem:

  • Include a mention of the UI Router module, for example using a CDN:

link

  • Declare the dependency on the initialisation of your application:

    var myApp = angular.module('app', ['ui.router']);

20.01.2016 / 20:19