How to make $ state.go () with parameters?

I perfectly initialized $ stateProvider and I use all of these states with ui-sref. It works great. The user clicks the button and transfers $ stateProvider to the edit page.

On this page, I have a form that asks for $ http:

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

                $state.go('roleInfo({roleId: $stateParams.roleId})');
            },
            function error(data) {
                console.log(data);
                $.notify({message: data.data.message},{type:'danger'});
            }
        );

    }

And I want to redirect to another view, if everything is in order. But this:

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

does not work. How can I make $ state.go with parameters?

+4
source share
3 answers

ui-sref $state.go, 1- stateName, Object.

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

:

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

+2

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

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

it will work


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

                   $state.go('roleInfo',{roleId :$stateParams.roleId});                    },
                function error(data) {
                    console.log(data);
                    $.notify({message: data.data.message},{type:'danger'});
                }
            );

        }
+1
source

All Articles