AngularJS : How to use $state.go to pass querystring in nested state routing

Shashwat Tripathi picture Shashwat Tripathi · Mar 10, 2015 · Viewed 13.7k times · Source

How can I use $state.go to pass a query string into nested state routing?

Code:

 .state('masterform', {
        url: "/masterform?action&assetId&contentTypeId&folderid",
                views: {
                    content: {
                        templateUrl: 'components/masterform/masterform.html',
                        controller: 'masterformCtrl as masterform'
                    }
                }
            })
            .state('masterform.access', {
                url: "/access",
                views: {
                    content: {
                        templateUrl: 'components/masterform/access/access.html',
                        controller: 'accessCtrl as access'
                    }
                }
            })

Thanks.

Answer

Rubi saini picture Rubi saini · Jun 5, 2015

You can simply pass query string parameters with second option of $state.go(). Like:

$state.go('masterform', {action:'Get', assetId:1234, folderId:999});