Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Call Client Controller Function inside the Server Script.

arizeciri
Tera Expert

Hello together,

I have a small issue.

Is it possible to call a Client Controller Funkcion inside a Server Script?

My plan is to show the current page title in the Header. But the problem is that the header doesnt reload when I switch the Pages.

When I switch the Pages only the Server Script is reloading but not the client controller. So I was about to call the Client controller, which sets the Title in the Header, with a Server Script Call.

 

I would be glad for any help.

Thank you!

1 ACCEPTED SOLUTION

Oh Great,

 

Make your answer as correct it will helpfull for others

View solution in original post

5 REPLIES 5

Chandu Telu
Tera Guru

Hi 

Please check the below link it may help you

https://community.servicenow.com/community?id=community_question&sys_id=d14503addbd8dbc01dcaf3231f9619f7

https://community.servicenow.com/community?id=community_question&sys_id=32f2c7a1dbd8dbc01dcaf3231f9619f8

https://community.servicenow.com/community?id=community_question&sys_id=d9e68fa5db1cdbc01dcaf3231f9619d0

arizeciri
Tera Expert

This works: ng-bind

HTML:

  <p id="portalTitle" style="margin: 0px" ng-bind="titleFct()"/>
  <span id="portalDescription" class="description" ng-bind="descFct()"/>  

Client Controller:

$scope.titleFct = function getTitle(){
		if(!$rootScope.page.title.toUpperCase().includes("INDEX")){
			return $rootScope.page.title;
		}else{
			return "";
		}
	};
	
	
	$scope.descFct = function getDescription(){
		if(!$scope.options.short_description && $scope.data.category){
			return $scope.data.category;
		}else{
			return "";
		}
	};

Oh Great,

 

Make your answer as correct it will helpfull for others

I cannot set my own answer as correct...