State Hook
π State Hook in Template
<div *useState="let x default 0">
<button (click)="x = x + 1">Press me: {{x}} π₯</button>
</div>π State Hook with Ivy
const initialValue = 0;
@Component({
selector: 'app-use-state',
template: `
<button (click)="setCount(count + 1)">
Press me: {{count}} π₯
</button>
`
})
@UseState(['count', 'setCount'], initialValue)
class Host {}
Last updated