Files
Matthieu Riegler 8eef694def feat(core): Provide a diagnostic for missing Signal invocation in template interpolation. (#49660)
To improve DX for beginners, this commit adds an extended diagnostic for Signals in template interpolations.

PR Close #49660
2023-10-10 11:55:13 -07:00

35 lines
835 B
Markdown

@name Signals must be invoked in template interpolations.
@description
Angular Signals are zero-argument functions (`() => T`). When executed, they return the current value of the signal.
This means they are meant to be invoked when used in template interpolations to render its value.
## What should I do instead?
When you use a signal within a template interpolation, you need to invoke it to render its value.
<code-example format="typescript" language="typescript">
import {Component, signal, Signal} from '&commat;angular/core';
&commat;Component({
// &hellip;
})
class MyComponent {
mySignal: Signal<number> = signal(0)
}
</code-example>
<code-example format="html" language="html">
&lt;div>{{ mySignal() }}/div>
</code-example>
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2023-04-02