1
I’m trying to run a simple code with angular and this warning stop on the console:
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.2/$injector/modulerr? P0=app&p 1=Error%3A%20%... angular.js:38
Follow 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 talk about the wrong controller injection, but as wrong?
you’re minifying the files?
– celsomtrindade
What do you mean? angular.js is using the web address: <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script>
– GustavoSevero
Minificado is the file that (by convention) has the extension
.min.js
, where the file is compressed. http://answall.com/questions/15019/qual-a-diff%C3%A7a-between-use-of-files-js-e-min-js– celsomtrindade
No, I’m not using min.js
– GustavoSevero
You only own a single state?
– celsomtrindade
The
["ngRoute"]
on the call of your module it doesn’t just work by adding this plugin: https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-route.min.js ? Did you? I could be mistaken, I’m not very experienced in Angular, but I imagined this.– Samir Braga
I already took the ngRoute but it didn’t help. Funny, because I have another application with angular and doesn’t have this problem.
– GustavoSevero
Another complimentary remark to @Samirbraga, I don’t know why you’re using the
ui-router
andngRoute
together... it’s very contradictory.– celsomtrindade
@Gustavosevero You only have one state?
– celsomtrindade
try adding this script https://docs.angularjs.org/api/ngRoute
– David Schrammel
Yes, just a state... However, I think it would not be necessary to put state, because I only have the index.html
– GustavoSevero
I was advised to use ui-route because ngRoute is being discontinued. @Davidschrammel.
– GustavoSevero
Is there another way to pass parameters? Because if I take the $stateParams, the problem comes out.
– GustavoSevero
I got... I took the route, the app.config and everything else, I left only the first line. See the modification in the post.
– GustavoSevero