簡體   English   中英

如何在Angular JS中刪除QueryString

[英]How to remove QueryString in Angular JS

我有一個網址http://sitename.com/#/products/manage-options/31?form_id=32&type=create-template

在我的網址上方,我想刪除type但在我的代碼下方,則無法正常工作。 請檢查

我當前頁面的網址-http: http://sitename.com/#/products/manage-options/31?type=create-template create- http://sitename.com/#/products/manage-options/31?type=create-template

<a href="" ng-click="clickMe();">Click Here</a>

$scope.clickMe = function(){
  $location.search('type', null);
  $state.go('products.manage_options', ({form_id: $stateParams.form_id}));
};

頁面重定向后,我看到type QueryString沒有刪除。

我的輸出是http://sitename.com/#/products/manage-options/31?form_id=32&type=create-template //sitename.com/#/products/manage-options/31? http://sitename.com/#/products/manage-options/31?form_id=32 - http://sitename.com/#/products/manage-options/31?form_id=32&type=create-template我想要http://sitename.com/#/products/manage-options/31?form_id=32

請幫我。

編輯:

路由器

.state('products.manage_options', {
        url: '/manage-options/:product_id?form_id=&type',
        templateUrl: "views/product/manage_options.html",
        controller: "manageAttributeCtrl",
        data: {pageTitle: 'Manage Options'},
})

去掉

$location.search('type', null);

更改以下行:

$state.go('products.manage_options', ({form_id: $stateParams.form_id, type:null}));

參見文檔https://docs.angularjs.org/api/ng/service/ $ location#search

     $state.go('products.manage_options', ({form_id: $stateParams.form_id, type:null}));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM