CONDITIONAL RENDERING, SHOW/HIDE
Overview
When it comes to handle specific part of a component/UI in order to hide/unhide or render conditionally, Stilljs provides with a proper directive.
The (showIf) - showIf
Directive example:
As the directive itself suggests, this directive will show
a content If
the assigned flag matches the stated condition, in case the condition is not matched, it'll hide the content.
It's mandatory to specify the container (see container directive) when using (showIf)
directive, and, in the container itself, we place our condition as follow bellow:
In the above example, the flag need to be boolean, in this case it will be checked that if it's true, then the data will be showed, otherise (if false), it'll hidden.
It's also possible to negate the (showIf)
- renderIf flag by putting ! before the flag itself, if that's the case we'll have the code as follow:
Using expresion as flag
It's also possible to use expression when using the (renderIf)
directive, for that, the expression needs to produce a boolean result as follow:
The (renderIf)
Directive example:
The (renderIf)
directive will not render the UI part if the flag value is false, whereas (showIf)
hides only giving the possibility of unhiding it afterwards.
Unlike (showIf)
, the (renderIf)
is flaged with a boolean only, means, expressions kind of flagging is not supported.