sam
sam

Reputation: 698

How to navigate from one page to another in ionic

Ionic v1

I was using ui-sref to simply navigate from one page to another in my ionic app, but recently have to switch to $state.go because pressing button closes the app. I figured it out that states are not maintained in ui-sref.

So my question is do I have to always use $state.go if I just want to simply navigate between pages without closing my app and create a separate function in controller to go to next page.

Code for ref

<button class=" button button-assertive" ui-sref="nextPage">Next</a>

or

<button class=" button button-assertive" ng-click="gotonext()">Next</a>

JS

$scope.gotonext = function(){  
    $state.go('nextPage')
};

Upvotes: 1

Views: 506

Answers (1)

Tejinder Singh
Tejinder Singh

Reputation: 1120

Try this :-

$scope.gotonext = function(){  
    $location.path("/nextPage");
};

Upvotes: 1

Related Questions