How to show a paragraph of text in SAPUI5 front end and make part of the text bold and…
- User
How to show a paragraph of text in SAPUI5 front end and make part of the text bold and part of the text as link?
- Assistant
To achieve this in SAPUI5, you can use the
FormattedTextcontrol. TheFormattedTextcontrol allows you to display formatted text, including bold text and links.First, add the
FormattedTextcontrol to your view XML file:xml<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"> <FormattedText id="myFormattedText" width="100%"></FormattedText> </mvc:View>In the controller file, you can then set the text property of the
FormattedTextcontrol with HTML tags to achieve the desired formatting:javascriptsap.ui.define([ "sap/ui/core/mvc/Controller" ], function(Controller) { "use strict"; return Controller.extend("your.controller", { onInit: function() { var sText = "This is <b>bold</b> text and this is a <a href='#'>link</a>."; this.getView().byId("myFormattedText").setHtmlText(sText); } }); });