How to redirect the page by click the button on service portal?

sri83
Tera Guru

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>

 

sri83_0-1669618109855.png

 

 

Regards,

Sri

9 REPLIES 9

Vasantharajan N
Tera Sage

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

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

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.

@sri83 it should work, either your page or portal is not correct or you have removed any OOB code from widget.

Akshay64
Tera Contributor

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

Akshay64_1-1669627001333.png