1.13.9. fejezet, Signal
Beküldte pzoli - 2024, október 30 - 1:26du
Kapcsolódó hivatkozások
- Angular Signals: The Complete Guide (Youtube)
app.component.ts
width = signal(10) height = signal(20) area = computed(() => this.width() * this.height()) constructor() { effect(() => { console.log("Effect due to width signal is triggered.", this.width()) }) effect(() => { console.log("Effect due to height signal is triggered.", this.height()) }) } incHeight() { this.height.update(() => this.height() * 2) } incWidth() { this.width.update(() => this.width() * 2) }
app.component.html
<p-button (onClick)="incWidth()">incWidth</p-button> <p-button (onClick)="incHeight()">incHeight</p-button> <br/><br/> {{area()}}
- A hozzászóláshoz be kell jelentkezni