Render processHtml using AngularJS

Is it possible to render portal.processHtml using angularJS ?

data-th-utext="${portal.processHtml({’_value=’ + value })}"

Isn’t AngularJS a pure front-end framework? If it has a pure templating language that avoids DOM manipulation and stuff (ala ReactJS) then it could be possible.

Since portal.processHtml is running on the server-side it’s not possible to call this on the client side. AngularJS is s pure client-side library and can therefore not execute any of our server-side functions.

The example you show above is how Thymeleaf does it. Thymeleaf is a server-side templating language and it also uses data-* tags. Angular and other client framework uses also data-* tags and that may be the reason that it can be confusing.

BR,
Sten Roger

Is there any particular reason why you can’t process the HTML server-side in the controller, using the portal lib processHtml(), and then serve this data to angularJS?

1 Like

No, you can do that. No problem.

I use this technique extensively, but I always run out of nested "s and 's if I do too much in Thymeleaf.

The easiest way I’ve found around this is to either pre-render the html in the controller or make a service that Angular can use to fetch the rendered html.

Pre-rendering the HTML in the controller is easy:

model.init = JSON.stringify(portalLib.processHtml({value: inputText}))

…and then simply

`
{{article}}

`
3 Likes

Hi,

You were right. I can easily process the HTML in the controller and then pass it to the view.
I missed that. :grin:

Thank you for your replies.