AngularJS – How do I change the State from Inside the Controller

inject $state service to your controller, then in your controller…

CONTROLLER

$scope.changeState = function () {
    $state.go('where.ever.you.want.to.go', {stateParamKey: exampleParam});
};

and add ng-click to your button

HTML

<button ng-click="changeState()">Change State</button>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)