这段代码给了我错误:[$injector:unpr]未知提供者:$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'); }; }]);
我错过了有关如何注入位置服务的内容吗?
我没有配置$locationProvider,但这样做似乎没有帮助.
解决方法
你忘记了$scope和$location附近的报价:
var app = angular.module('myApp.controllers',['$scope','$location',if true do this: $location.path('/view2'); }; }]);
这应该是诀窍!