1
Good morning, everyone!
I am trying to make a Function with $Location.path('/main'); and when the function, the following message appears on the console:
Typeerror: Cannot read Property 'path' of Undefined
Why is that?
.controller('loginCtrl', ['$scope', '$stateParams', function ($scope, $stateParams, $http, $location) {
$scope.fazerLogin = function(usuario){
/*$http.post("", usuario).success(function(data){
});*/
$location.path('/main');
}
}])
Blz, it worked. But why do I have to put ['$http', '$Location', Function... tb? Recent change?
– GustavoSevero
It is not change, you have to declare all the properties you will use, otherwise it is without reference, and so gave
undefined
– Sorack
But in another application I have, I didn’t do it that way and it works!!
– GustavoSevero
@Gustavosevero you probably did not declare any, it works. This way of declaring as
string
serves for when you will minify the file. Here is an explanation in the documentation Dependency Injection. If you want you can open another question asking the staff to explain in detail– Sorack