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.

Variable Widget String Format (Break tag)

Johny1
Tera Expert

Hi Everyone,

I have created a widget for variable for service portal.

Can anyone tell how to apply break or next line for the below code

find_real_file.png

XYZ: string should come in second line. How to apply a break tag for this. Please help.

Thanks

Johny

1 ACCEPTED SOLUTION

Have you changed the HTML template as i directed?



You need to have a tag something like the below. The "ng-bind-html" is what causes it to render the <br/> tag as HTML rather than text


<h3 ng-bind-html="c.title"></h3>


View solution in original post

4 REPLIES 4

andrew_venables
ServiceNow Employee
ServiceNow Employee

You'll probably want to use a standard html line break: <br/>. However the issue is that this will be encoded and displayed literally on the page which you don't want:


Screen Shot 2017-12-18 at 09.56.50.png



So you also have to use a special directive in the HTML, like so:



Widget HTML Template:


<h3 ng-bind-html="c.title"></h3>



Client Script:


function($scope) {


  /* widget controller */


  var c = this;


  c.title = 'foo <br/> bar';


}


Result:


Screen Shot 2017-12-18 at 09.55.24.png



See the docs. Here is a example.


Thank you Andrew. Break tag is not working and the result string is showing including the brk tag



find_real_file.png



Result:


find_real_file.png



Thanks


Johny


Have you changed the HTML template as i directed?



You need to have a tag something like the below. The "ng-bind-html" is what causes it to render the <br/> tag as HTML rather than text


<h3 ng-bind-html="c.title"></h3>


Thanks a lot Andrew. It worked