/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
devtools/src/app/demo-app/cookies.component.ts
38 строк
1 KB
Matthieu Riegler
ci: reformat files
17 дек 2025, 01:44
17 дек 2025, 01:44
6270bba
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Component, signal, computed} from '@angular/core'; @Component({ selector: 'app-cookies', template: ` <h2>Cookie recipe</h2> <label> # of cookies: <input type="range" min="10" max="100" step="10" [value]="count()" (input)="update($event)" /> {{ count() }} </label> <p>Butter: {{ butter() }} cup(s)</p> <p>Sugar: {{ sugar() }} cup(s)</p> <p>Flour: {{ flour() }} cup(s)</p> `, }) export class CookieRecipe { count = signal(10, {debugName: 'count'}); butter = computed(() => this.count() * 0.1, {debugName: 'butter'}); sugar = computed(() => this.count() * 0.05, {debugName: 'sugar'}); flour = computed(() => this.count() * 0.2, {debugName: 'flour'}); update(event: Event) { const input = event.target as HTMLInputElement; this.count.set(parseInt(input.value)); } }