// To assign a property called mydiv on the binding context that contains a div// element<divref="mydiv"></div>// Binding using translations<div>&{person.lastName}</div>// Binding in textContent<div>${person.firstName}</div>
Binding directions
// Once binding<my-componentgreeting.once="greeting"></my-component>// One way binding<my-componentvalue.one-way="person.firstName"></my-component>// Two way binding<inputvalue.two-way="person.lastName" />// Using bind expression<inputvalue.bind="person.age"type="number" />
// Standard attribute binding<divdata-value.attr="age"></div>// Toggle attribute using "true" and "false"<buttonclick.attr.toggle="[this](aria-expanded='true')">Toggle Expanded</button>// Add and remove attribute using toggle<buttonclick.attr.toggle="[this](data-hidden)">Toggle Hidden</button>// Simple conditional attribute binding. Set if value passes, remove if not<divdata-value.if="age < 20 ? 'young'"></div>// Simple conditional attribute binding with if / else<divdata-value.if="age < 20 ? 'young' : 'old'"></div>// Attribute case condition binding with default value<divdata-value.case="age < 20: 'young', age < 30: 'mid', default: 'old'"></div>// Attribute case condition binding without default value<divdata-value.case="age < 20: 'young', age < 30: 'mid'"></div>
Array binding
<templatefor="item of items"> <li>${item.code}</li></template>
// Toggle global value<buttonclick.setvalue="$globals.menuVisible = !$globals.menuVisible">// Toggle context property<buttonclick.setvalue="state2 = !state2">// Simple set value<buttonclick.setvalue="state = 'on'">// Conditional set value<buttonclick.setvalue="state = state == 'on' ? 'off' : 'on'">// Set context property to element property<buttonclick.setvalue="state = prop(#input, value, true)">// Set context property based on element condition<buttonclick.setvalue="state = prop(#input, value, true)==1 ? 'off' : 'on'">// Set attribute value <buttonclick.setvalue="attr(#static1, data-value, true) = 'on'">// Set attribute to attribute<buttonclick.setvalue="attr(#static1, data-value, true) = attr($element, data-value, true)">// Set element property based on this element's property<inputchange.setvalue="prop(#input2, value, true) = prop($element, value)"/>
Messaging
// use event aggregation emit with event key<buttonclick.emit="my_event">// emit with parameters<buttonclick.emit="my_event(title='hello world', $event, contacts=${contacts})">// post message to component with id "#selector" with event key of "my_event"<buttonclick.post="my_event['#selector'](title='hello world')">// call a process api module<buttonclick.process="{type: 'console', action: 'log', {messages: ['hello', 'world']}}">// call a process api module from a defined schema<buttonclick.process="schema_name[process_name(param1: 10, param2: 'B')]">