@microsoft/fast-element > when

when() function

A directive that enables basic conditional rendering in a template.

Signature:

export declare function when<TSource = any, TReturn = any, TParent = any>(condition: Expression<TSource, TReturn, TParent> | boolean, templateOrTemplateBinding: SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>, elseTemplateOrTemplateBinding?: SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>): CaptureType<TSource, TParent>;

Parameters

Parameter

Type

Description

condition

Expression<TSource, TReturn, TParent> | boolean

The condition to test for rendering.

templateOrTemplateBinding

SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>

The template or a binding that gets the template to render when the condition is true.

elseTemplateOrTemplateBinding

SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>

(Optional) Optional template or binding that that gets the template to render when the conditional is false.

Returns:

CaptureType<TSource, TParent>