Chinu Chinu - 2 months ago 5
Javascript Question

How to remove QueryString in Angular JS

I have an URL

http://sitename.com/#/products/manage-options/31?form_id=32&type=create-template


Here above my URL I want to remove
type
but below my code not working properly. Please Check

My Current page URL -
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}));
};


After page redirecting I saw
type
QueryString not removed.

My output is -
http://sitename.com/#/products/manage-options/31?form_id=32&type=create-template
I want
http://sitename.com/#/products/manage-options/31?form_id=32


please help me.

EDIT:

Router

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

Answer

Remove

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

Change following line :

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