sarveshwar geetha sarveshwar geetha - 3 months ago 9x
Javascript Question

Cannot read property 'go' of undefined with registerForm

I want to change my state to "login" on a button click . So , i added a button and in ng-click , i called up the function "registerForm"(which u can see in the below code). but when i press the button i get the following error in the browser console.

TypeError: Cannot read property 'go' of undefined

at m.$scope.registerForm (controllers.js:27)

at fn (eval at compile (angular.js:14605), :4:227)

at b (angular.js:15694)

at e (angular.js:25622)

at m.$eval (angular.js:17444)

at m.$apply (angular.js:17544)

at HTMLFormElement. (angular.js:25627)

at Sf (angular.js:3488)

at HTMLFormElement.d (angular.js:3476)

app.controller('registerController', ['$scope',function ($scope,$state) {

$scope.$watch('retypepassword', function()
if($scope.password === $scope.retypepassword)
$scope.loginForm.$setValidity("valid", true);

$scope.loginForm.$setValidity("valid", false);

}, true);

$state.go('login', {});



Inject $state properly

app.controller('registerController', ['$scope', '$state', function ($scope,$state) {