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:13 PM
Why don't you use exiting widget named "link-button" which helps you achieve your requirement without any custom widget. or you can refer to the "link-button" widget for reference.
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 12:11 AM
Hi vasanthrajan,
As per my requirement, when the click the first button on portal it should redirect to another page icon in that page i want to add the 3 more button for showing the page.
Regards,
Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 12:41 AM
Below code should redirect you to the desired page, if that exists:
var c = this;
c.location = function()
{
alert("test");
window.location.href = "https://www.XXXXXXXXXXX.com/";
}
Are you getting any errors in this? if yes check the console and reply with the error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 01:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 01:16 AM - edited 11-28-2022 01:16 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. That needs to be corrected