What's a difference between "on" and "when" in the new angular defer block

62 views Asked by At

New Angular defer block comes with some new features.

We can use when element as well as on element. What's the difference between them?

@defer (when isReady) {
 <span appFoo>
  {{ 'foo' | upperCasePipe }}
 </span>
 }

vs

@defer (on interaction) {
  <span appFoo>
    {{ 'foo' | upperCasePipe }}
    </span>
} @placeholder {
  <button>Trigger loading!</button>
}
1

There are 1 answers

0
Matthieu Riegler On

on is meant to be used with the built-in triggers: interaction, hover, immediate, idle, timer and viewport.

when works with component variables/methods.