Reputation: 363
This code gives me Error: [$injector:unpr] Unknown provider: $scope, $locationProvider <- $scope, $location
.
var app = angular.module('myApp.controllers', []);
app.controller('Signup', ['$scope, $location', function($scope, $location) {
$scope.checkEmailValid = function(){
//TODO make a decision about whether to go somewhere, if true do this:
$location.path('/view2');
};
}]);
Am I missing something about how to inject the location service? I haven't configured $locationProvider, but doing so doesn't seem to help.
Upvotes: 4
Views: 5591
Reputation: 1003
Try simpler form (without array form - probably missing quote is your problem):
app.controller('Signup', function($scope, $location) {
$scope.checkEmailValid = function(){
//TODO make a decision about whether to go somewhere, if true do this:
$location.path('/view2');
};
});
Minification can be solved in build time using ngMin and this form is less error prone and more readable
Upvotes: 1
Reputation: 1734
You forgot the quotes around $scope and $location :
var app = angular.module('myApp.controllers', []);
app.controller('Signup', ['$scope', '$location', function($scope, $location) {
$scope.checkEmailValid = function(){
//TODO make a decision about whether to go somewhere, if true do this:
$location.path('/view2');
};
}]);
This should to the trick !
Upvotes: 5