- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2018 08:09 AM
I am working in the Service Portal. The script below works on page reload or refresh.
However with I click a link on the page that changes the url, for instance like on a
single page application. The script does not fire. Can this be done in AngularJS?
If so how can that be done? Or should this JavaScript be done differently?
Thanks in advance for you wisdom and help.
<script type="text/javascript">
$(document).ready(function () {
if(window.location.href.indexOf("table=sc_cat_item") > -1) {
alert("your url contains the name table=sc_cat_item");
}
});
</script>
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 08:35 AM
I had mentioned this in the other post as well, but you don't need the ( at the beginning of the client controller or the )(); at the end of it. those are probably causing your issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 07:08 AM
Console says:
" $scope is not defined"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 07:23 AM
function($scope, $location) {
/* widget controller */
var c = this;
function checkLocation() {
var loc = $location.search();
if (loc.table == 'sc_cat_item') {
alert("works");
}
}
$scope.$on('$locationChangeSuccess',function() {
checkLocation();
});
checkLocation();
})();
Now the console says:
TypeError: Cannot read property '$on' of undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 08:35 AM
I had mentioned this in the other post as well, but you don't need the ( at the beginning of the client controller or the )(); at the end of it. those are probably causing your issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2019 06:13 AM
Hi Jon,
Can you help me with the below code. I need to change the URL without refresh. I did using $location.search and provided spa=1. It is not working. Below is my code.
<div ng-click='c.AddManualTask(task.catalog_id, task.element_id, task.state)'>
function($location) {
var c = this;
c.AddManualTask = function(catalogID, element_id, state)
{
if(state == 'Complete')
{
$location.url('snappi?sys_id='+element_id+'&view=sp&id=fr_plan_details&table=sc_req_item&mode=new&snappi_id='+c.data.snappiId+'+&phase_id='+c.data.phaseId);
}
else
{
$location.url('snappi?id=fr_plan_details&sys_id='+catalogID+'&mode=new&dynamic=false&snappi_id='+c.data.snappiId+'+&phase_id='+c.data.phaseId);
}
