Redirect $state.go not working Ionic V1

Hi I have a forgot password link on my login screen, but if I click on it it does not redirect me to the specified page.

I have already done much r&d on it but nothing working.

//View
<div ng-controller="forgotPasswordController"><h6 class="forget-password"><a ng-click="forgetPassword()">Forgot 
Password ?</a></h6></div>


//app.js
.state('forgotpassword', {
      url: '/forgotpassword',
      templateUrl: 'templates/forgotpassword.html',
      controller: 'forgotPasswordController'         

      })

//controller.js
app.controller('forgotPasswordController',function($scope,$state,$location,forgotPasswordService,$ionicLoading,Flash, 
$http, $ionicPopup, sessionService)
{ 
    $scope.data = {};        
    $scope.userDetails =   sessionService.get('userDetails');
    $scope.forgetPassword = function() {alert("dfdsf");
    //$state.go("forgotpassword");
    $location.path( "/forgotpassword" );
   // $location.url('/forgotpassword');
}
});

It is not redirecting to the forgotpassword page. Even not giving any error / exception as well. Can any one suggest what could be the issue in this.

Thanks in advance

try this $state.go(‘forgotpassword’);

already tried everything. nothing working

your adding the function in the forgotpassword but you must add it in where page it should really be… am I right? because as far as I understand your are already in the forgotpassword page and you literally go to the same page again which really will not work because it is your active page already…

I am on login page. not forgotpassword page.

and here a link Forgot password, I want to redirect a page to (‘forgotpassword’) if user click on this link.

Please check screen-shot

where is the function of redirecting from login to forgot? please paste the code

//login.html

<div ng-controller="forgotPasswordController"><h6 class="forget-password"><a ng-click="forgetPassword()">Forgot 
Password ?</a></h6></div>    

//controller.js

app.controller('forgotPasswordController',function($scope,$state,$location,forgotPasswordService,$ionicLoading,Flash, 
$http, $ionicPopup, sessionService)
{ 

    $scope.data = {};        
    $scope.userDetails =   sessionService.get('userDetails');
    $scope.forgetPassword = function() {
    $state.go('forgotpassword');         

}
});

sorry but your not in logincontroller…

Your routing must be like this

Index(login) page ----> LoginController

 here should be the redirecting function you must add...

Forgot page -----> ForgotController

You mean.

<div ng-controller="LoginController"><h6 class="forget-password"><a ng-click="forgetPassword()">Forgot 
Password ?</a></h6></div> 

?

app.controller('LoginController',function($scope,$state,$location,forgotPasswordService,$ionicLoading,Flash, $http, 
$ionicPopup, sessionService)
{ 

    $scope.data = {};        
    $scope.userDetails =   sessionService.get('userDetails');
    $scope.forgetPassword = function() {
    $state.go('forgotpassword');         
}

});

Still not working.

$scope.forgetPassword= function () {
      $state.go('forgotpassword');
};

you are not enclosing the forgetpassword with curly braces end tag…

Its closed in my code I missed it while pasting code here

you should use codepen to be able others to take a look at your code and initialize what is wrong with your code.

ok,let me use it then will share here

as far as I understand your code is correct maybe something just preventing it from going to another page or maybe your routing config is wrong?

Yes, that why I am feed-up now, not able to identify what is the exact issue. Its took mine long time as well.

Its working now. Thanks @anicacute09 for your help

so what’s the problem? how do you solved it? please tell us for the others if facing the same problem can give us hints how can they solve it…

just changes controller as:

<div ng-controller="LoginController"><h6 class="forget-password"><a ng-click="forgetPassword()">Forgot Password ?</a></h6></div>

As it was forgotPassword Controller before on Login page.

ah I see common mistakes that we encounter day to day coding… Good job finding that… Happy coding

Sorry, actualy that day I have just logged in and then only, I redirect to forgot password link.

Issue is still pending, I thought its was working, because after login then only it allow to redirect. not from login page.

Is there a way to redirect a forgot password state as public without (Authentication).