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。