Himmet Avsar
Himmet Avsar

Reputation: 1531

Angularjs ui router manual navigation

I want to manually change the current state within my controller using the ui router.

I have the following code at the moment:

<button ng-click="go()">Go</button>

    controllers.controller("MyController", function($scope){
        $scope.go = function(){
            //Manually change state
        };
    });

Is there something like

$uiRouter.changeState("mystate"); ?

Thanks in advance!

Upvotes: 3

Views: 2595

Answers (1)

akonsu
akonsu

Reputation: 29536

you can use $state.go or $state.transitionTo (https://github.com/angular-ui/ui-router/wiki/Quick-Reference#statetransitiontoto-toparams--options)

controllers.controller("MyController", function($scope, $state){
    $scope.go = function(){
        $state.go('new-state');
    };
});

Upvotes: 10

Related Questions