我想在点击按钮时将我的状态更改为“登录”。所以,我添加了一个按钮,在 ng-click
中调用了函数 registerForm
(您可以在下面的代码中看到)。但是当我按下按钮时,浏览器控制台会出现以下错误。
类型错误:无法读取未定义的 'go' 属性
在 m.$scope.registerForm (controllers.js:27)
在 fn (eval at compile (angular.js: 14605), :4:227)
在 b (angular.js:15694)
在 e (angular.js:25622)
在 m.$eval (angular.js:17444)
在 m.$apply (angular.js:17544)
在 HTMLFormElement. (angular.js:25627)
在 Sf (angular.js:3488)
在 HTMLFormElement.d (angular.js:3476)
app.controller('registerController', ['$scope',function ($scope,$state) {
$scope.mismatch=true;
$scope.$watch('retypepassword', function()
{
if($scope.retypepassword != null)
{
if($scope.password === $scope.retypepassword)
{
$scope.mismatch=true;
$scope.loginForm.$setValidity("valid", true);
}
else
{
$scope.mismatch=false;
$scope.loginForm.$setValidity("valid", false);
}
}
}, true);
$scope.registerForm=function()
{
$state.go('login', {});
}
}]);