$location.url should not refresh the page

Vikram3
Giga Guru

Hi All,

Below HTML will be added in left nav as shown

<div>
  <label class="container" ng-repeat="task in data.iterativeTasks">
    <div class="result-id">
      <p>Project Id:</p>
    
    <div class="result" ng-click='c.AddManualTask(task.catalog_id)'>{{task.name}}</div>
      </div><br>
    <div class="result-id">
      <p>Created on:</p>
    </div>
    <div class="result">{{task.catalog_id}}</div>
    <input type="radio" checked="checked" name="radio">
    <span class="checkmark"></span>
  </label>
</div>

find_real_file.png

On click of Project Id it will go to another URL,

function($location) {  /* widget controller */  var c = this;
					 
					 c.AddManualTask = function(catalogID)
						{
						 $location.url('snappi?id=fr_plan_details&sys_id='+catalogID+'&mode=new&dynamic=false&snappi_id='+c.data.snappiId+'+&phase_id='+c.data.phaseId);
						}
					}

After click the page is getting refreshed and becomes like this,

find_real_file.png

On the whole, subcategories are closed. My question is, how to stop refreshing the page after changing the URL.

Thanks in advance.

1 ACCEPTED SOLUTION

Jon Barnes
Kilo Sage

if you aren't changing portals, just try using this:

$location.search({
  id: 'fr_plan_details',
  sys_id: catalogID,
  mode: 'new',
  dynamic: 'false',
  snappi_id: c.data.snappiId,
  phase_id: c.data.phaseId
});

View solution in original post

9 REPLIES 9

Hi Jon,

URL is getting changed. But the content is not getting populated. It shows the previous page contents only.

This is an awesome post, searched forever on how to create a new feedback record and redirect without a full refresh so our VA Chat Session wouldn't restart.

Prins Kumar Gup
Giga Guru

Hi,

Please see the below link:

Service Portal, $location. Works on page reload only

You can also try the below code: 

c.refresh = function(){

window .location.reload();

return;

}

 

 

But where to provide the URL here?

I wouldn't do a window.location.reload in an angular app. $location works on initial page load, just locationchangesuccess event may not work on initial page load.