Open History to see the last commit
1import { injectStore } from '@tanstack/angular-store'
2import { Component, input } from '@angular/core'
3import { store } from './store'
4β
5@Component({
6 selector: 'app-display',
7 template: `
8 <!-- This will only re-render when animal changes. If an unrelated store property changes, it won't re-render -->
9 <div>{{ animal() }}: {{ count() }}</div>
10 `,
11})
12export class DisplayComponent {
13 animal = input.required<'cats' | 'dogs'>()
14 count = injectStore(store, (state) => state[this.animal()])
15}