How to redirect the page by click the button on service portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 10:50 PM
Hi Team,
I have created the button on portal form. When i click the button, it should redirect to another page but the script is not working and redirection is not happening please help me.
Code:
Client Controller:
var app = angular.module('Demo', []);
app.controller('Sample', function($scope, $window, $location) {
$scope.location = function(){
var url = "https://www.XXXXXXXXXXX.com/";
$window.location.href = url;
}
});
HTML:
<div ng-app="Demo" ng-controller="Sample">
<button ng-click="location()">Click here</button>
</div>
Regards,
Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 11:00 PM - edited 11-27-2022 11:01 PM
Try below:
HTML:
<div >
<button ng-click="c.location()">Click here</button>
</div>
client:
var c = this;
c.location = function()
{
window.location.href = "https://www.XXXXXXXXXXX.com/";
}
Please mark the answer correct/helpful accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 11:12 PM
Hi Raghv,
Thanks for the quick reply.
I have tried the above script but it's not working for me. Please do suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 11:23 PM - edited 11-27-2022 11:25 PM
This should work, you have removed the OOB code of client script, can you add that and try?
Also Demo, is that the name of your portal?
Try to add alert as well in c.location function in client controller
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 01:07 AM - edited 11-28-2022 01:10 AM
Hi,
It should work,below i have passed instance url just for testing and it's navigating to instance page as expected. kindly check the url/page which you passed in client script.