登录后重定向页面 - Angularjs 和 Kinvey

Redirect page after signIn - Angularjs and Kinvey

当我尝试将页面重定向到 index.html 时,出现以下错误:$location 未定义。 当用户和密码正确时,我只需要重定向到索引页面。

 app.controller('loginController', ['$scope', '$kinvey',  function($scope, $kinvey, $location) {


     $scope.login = function() {

          var promise = $kinvey.User.login({
                username : $scope.username, 
                password : $scope.password
            });

            promise.then(function(response) {
              console.log('User in');
              $location.path('/index.html');

            }, function(err) {
               console.log(err);
            });  
      }

  }
 ]);

您忘记在参数中添加 $location:

app.controller('loginController', ['$scope', '$kinvey','$location'/*here*/,  function($scope, $kinvey, $location)