Conditional Rendering
You can use the structural directive if
to conditionally render an element. if
works in the form of if={expression}
, if the expression evaluates to a truthy value, the host element will be rendered, otherwise removed from the DOM.
In the following example, the span whose context is ‘Completed’ will be rendered.123456<div id="app1"> <span> <span if="{model.isCompleted}">Completed</span> <span if="{!model.isCompleted}">Not completed</span> </span></div>
|
|
Completed
Not completed
Copyright © 2019 Alex Ou