AngularJS:如何使用$ state.go在嵌套状态路由中传递查询字符串

Sha*_*thi 11 angularjs-routing

如何使用$state.go将查询字符串传递给嵌套状态路由?

码:

 .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'
                    }
                }
            })
Run Code Online (Sandbox Code Playgroud)

谢谢.

Rub*_*ini 16

您可以使用第二个选项简单地传递查询字符串参数$state.go().喜欢:

$state.go('masterform', {action:'Get', assetId:1234, folderId:999});
Run Code Online (Sandbox Code Playgroud)

  • 请注意,您可能需要更新应用程序“$stateProvider”,例如:“$stateProvider.state('Get', { params: { assetId: -1,folderId: -1}})”。 (2认同)