Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJS-URL参数未在$state.go()上保留_Angularjs - Fatal编程技术网

AngularJS-URL参数未在$state.go()上保留

AngularJS-URL参数未在$state.go()上保留,angularjs,Angularjs,我正在使用$state.go更改状态。假设状态A的查询参数为: /#/?city=xyz&state=abc&foo=bar 当我将状态更改为B时,url参数将丢失: $rootScope.$state.go('B',$location.search()) B国声明: .state('B', { url: "/search.html", templateUrl: "views/search.html",

我正在使用
$state.go
更改状态。假设状态A的查询参数为:

/#/?city=xyz&state=abc&foo=bar
当我将状态更改为B时,url参数将丢失:

$rootScope.$state.go('B',$location.search())
B国声明:

.state('B', {
            url: "/search.html",
            templateUrl: "views/search.html",
            reloadOnSearch: false,
            data: {
                pageTitle: 'Search Results'
            },
            controller: "SearchPageController",
            resolve: {
在状态B,状态A中不存在url参数:

/#/search.html

使用$state.go时,必须标识要传入的所有参数。手动使用$location.path可能更有意义,这样可以维护查询参数

因此,而不是
$state.go('B')

只需说
$location.path('/search')

侧注:您的url不需要在末尾有.html。