Example of a simple control with a name property
The control is used to render the text "Hello <name>":
#!js sap.ui.core.Control.extend("my.Hello", { // call the new Control type "my.Hello" // and let it inherit from sap.ui.core.Control metadata : { // the Control API properties : { "name" : "string" // setter and getter are created behind the scenes, // including data binding and type validation } }, renderer : function(oRm, oControl) { // the part creating the HTML oRm.write("<span>Hello "); oRm.writeEscaped(oControl.getName()); // write the Control property 'name', with XSS protection oRm.write("</span>"); } });
The new control is ready for use now. To instantiate and display the control, use the following code:
#!js new my.Hello({name:"UI5"}).placeAt("content");