$rootScope.$digest is clearing params

45 Views Asked by At

I have problem with window.history.pushState method. I'm on page https://localhost:1234/jobs. I want to add one parameter and hash to my url without reloading a page. I have a simple button to edit job:

<i class="fas fa-edit fa-fw"
   data-tooltip="tooltip"
   title="Edit this job"
   ng-click="goJobModal(job.id);$event.stopPropagation()"></i>

After pressing this, goJobModal should be executed with job.id

$scope.goJobModal = function(jobId) {
  if (jobId) {
    window.history.pushState(null, "Updating job", "/jobs/?jobId=" + jobId + "#update");
    console.log(window.location.href);
  } else {
    window.history.pushState(null, "Creating job", "/jobs#create");
  }
};

I placed a breakpoint in line with console.log to look what happens after pushState and I saw something iteresting for me. After $rootScope.$digest my url was cleared to https://localhost:1234/jobs. What should I do to successfully change my url?

0

There are 0 best solutions below