How to redirect one controller to other controller after onclick on button?


Hi All,

I want to redirect listing to description with out using href. How can redirect?? Can any one help me??


I am trying to use window.location="#/app/players/6" it is working first time but not second time…


You could use the $state service in angular.


Don´t forget to include the $state service into your controller. You could put the above code into a method call goToSite(). Then you could call that method onClick with ng-click.

Hope this helps


Thanks…for reply…

I want to go friend detail page how i can redirect using $state object???


Just change “tab.friends” with the aquivalent state of your detail page. e.g. “detailFriend”


You would use something like ng-click="goToFriendDetail()" attribute in the clickable item where the function would be defined in your controller like:

$scope.goToFriendDetail = function() {

You would define a state for friend.details in your routing rules in app.js.


You are discussing different… i want different… :slight_smile:
friends page content list of friends … On click on any friend list item . it should open that friend detail.
That miens each friend have id and it will redirect as per the id…ok …
In that case, how can use $state.go…


Hi shashikant,

maybe this is what you need:

I use it to display a user profil after click on a list with users.



I know the redirection usign href…
but i want to do $state.go .


Then like this:

$state.go("friendDetail", {
                "friendId": $scope.friendId


So define a state for the detail screen something like this:

$stateProvider.state('friend.details', {
    url: '/friend/detail/:id',
    templateUrl: 'templates/friendetail.html',
    controller: 'FriendCtrl'



Thanks …for reply…
I know Using $stateProvider. But i want to redirect List to detail from controller.

If there is a button on list page. Onclick on button it should open 5th product detail. How we can use…??
Using javascript it is working…
JavaScript ex- window.location = “#/app/lists/5”;

but i want to do using angular js/Ionic. How can i do ???


Not sure what the ‘problem’ is. You can either use an ng-click attribute specifying a function that changes state (example above), OR you can use ui-sref attribute an any element if you have named states defined. Both do the same thing, either way, you are telling the app to transition from one state to the next.