Constructor
new TextComponent(optionsopt)
Parameters:
Name |
Type |
Attributes |
Default |
Description |
options |
Object
|
<optional>
|
{}
|
see the Component options
Properties
Name |
Type |
Attributes |
Default |
Description |
text |
string
|
<optional>
|
''
|
the initial text shown in the heading |
dataField |
string
|
<optional>
|
null
|
a field in the dataObject to bind to as the text |
dataFieldFormatter |
function
|
<optional>
|
null
|
a function that takes in a dataField value and returns a string |
|
- Source:
Examples
Show static text
const textComponent = new TextComponent(undefined, {
text: 'Static text goes here'
})
Show dynamically bound text
const textComponent = new TextComponent(myDataModel, {
dataField: 'title'
})
Show dynamically bound and formatted text
// Displays either 'Is active' or 'Is not active', depending on the data field
const textComponent = new TextComponent(myDataModel, {
dataField: 'isActive', // a boolean field
dataFieldFormatter: (value) => { return value === true ? 'Is active' : 'Is not active' }
})