ottercoder ottercoder - 1 year ago 189
AngularJS Question

How to do $state.go() with params?

I have perfectly initialized $stateProvider and I'm using all this states with ui-sref. Works great.
User presses the button and thorugh the $stateProvider goes to the edit page.

On this page I have a form which does $http request:

this.pushData = function (data) {
$'/data/' + $stateParams.dataId + '/otherdata', JSON.stringify({
}), configAuth).then(
function success(response) {
var addedData =;
$.notify({message: + " has been added"},{type:'success'});

$state.go('roleInfo({roleId: $stateParams.roleId})');
function error(data) {


And I want to do redirect to other view if everything is fine. But this:

$state.go('roleInfo({roleId: $stateParams.roleId})');

doesn't work. How can I do $state.go with params?

Answer Source

The way you are trying that would work with ui-sref directive, while calling it using $state.go method, you should pass 1st parameter is stateName & then pass params in Object format.

$state.go('roleInfo', {roleId: $stateParams.roleId});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download