无法注入$ location服务

Kne*_*ewB 4 angularjs angularjs-service

这段代码给了我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');
    };
}]);
Run Code Online (Sandbox Code Playgroud)

我错过了有关如何注入位置服务的内容吗?我没有配置$ locationProvider,但这样做似乎没有帮助.

Ale*_*xHv 5

你忘记了$ 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');
    };
}]);
Run Code Online (Sandbox Code Playgroud)

这应该是诀窍!