Reputation: 2379
How clear routeparam
in angularjs
from controller.
I am using routeparam
for updating a task,in popup.
url :- http://invoice.local/#/expenses/9
When route param exist,I open model box with form to update expense details,After successful update,I want to clear routeparam
. Otherwise model box opening again.
/**
* Open expense details if expense id in route param
*/
if ($routeParams.expenseId) {
expenseService.get($routeParams.expenseId)
.success(function (data) {
$scope.expense = expenseService.updateDateFormat(data, false);
$('#ModelBox').modal('show');
});
}
saving, refreshing current page,
$route.reload()
Here I want to clear routeparam and need to reload http://invoice.local/#/expenses/
Upvotes: 2
Views: 2180
Reputation: 1350
You can use $location for clearing parameters:
$location.search('expenseId', null)
but what you want is to change the path:
$location.path('/expenses')
This will load the expenses page, removing expenseId parameter and you can skip$route.reload()
, it will reload the page.
Upvotes: 2