Angularjs 向UI路由器路由添加查询字符串

Angularjs 向UI路由器路由添加查询字符串,angularjs,angular-ui-router,Angularjs,Angular Ui Router,我有一个ui路由器路由,定义如下 $stateProvider .state('search', { url: '/search', abstract: true, parent: 'loggedIn', views: { wrapper: { controller: 'MyCtrl',

我有一个ui路由器路由,定义如下

        $stateProvider
        .state('search', {
            url: '/search',
            abstract: true,
            parent: 'loggedIn',
            views: {

                wrapper: {
                    controller: 'MyCtrl',
                    controllerAs: 'myCtrl',
                    templateUrl: '/scripts/views/search/views/search.wrapper.html'
                }
            }
        })
        .state('search.subs', {
            url: '',
            resolve: {
                isLoggedIn: isLoggedIn
            },
            views: {
                body: {
                    controller: 'SearchBodyCtrl',
                    controllerAs: 'searchBodyCtrl',
                    templateUrl: '/scripts/views/search/views/search.body.html'
                }
            }
        });

无论如何,问题是我无法生成一个查询参数,使url看起来像
/search?hello=world
我尝试使用
$state.transition('search.subs',{hello:'world})
,但这不起作用。我认为我传递的任何不匹配的参数都会被放入查询字符串中,但事实并非如此

这应该是您想要做的:

    .state('search.subs', {
        url: '?hello', // This appends to the parent url
          ....
之后,您可以使用
$state.go('search.subs',{hello:'world'})
转换到search.subs状态


是的,我真的希望有一个动态API,但事实证明没有(