javascript - Remove routeparam from controller in angularjs? -
how clear routeparam
in angularjs
controller.
i using routeparam
updating task,in popup.
url :- http://invoice.local/#/expenses/9
when route param exist,i open model box form update expense details,after successful update,i want 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 want clear routeparam , need reload http://invoice.local/#/expenses/
you can use $location clearing parameters:
$location.search('expenseid', null)
but want change path:
$location.path('/expenses')
this load expenses page, removing expenseid parameter , can skip$route.reload()
, reload page.
Comments
Post a Comment