14

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.

Alfie J. Palmer
  • 827
  • 2
  • 15
  • 30
Shashwat Tripathi
  • 572
  • 1
  • 5
  • 19

1 Answers1

20

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

$state.go('masterform', {action:'Get', assetId:1234, folderId:999});
Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Rubi saini
  • 2,515
  • 23
  • 21
  • 2
    please note that you will probably need to update application `$stateProvider`, like: `$stateProvider.state('Get', { params: { assetId: -1, folderId: -1}})`. – Arsen Khachaturyan Nov 16 '18 at 15:52