From 6c3a1040c1e5d50b4c71862dab6ff27b9d14b774 Mon Sep 17 00:00:00 2001 From: Johannes Hoppe Date: Sun, 3 Nov 2024 10:50:47 +0100 Subject: [PATCH] firstBook = linkedSignal(() => this.books()[0]); --- src/app/books/book-list.component.ts | 3 +++ src/app/books/book/book.component.ts | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/books/book-list.component.ts b/src/app/books/book-list.component.ts index 71aa470..4e501ca 100644 --- a/src/app/books/book-list.component.ts +++ b/src/app/books/book-list.component.ts @@ -15,6 +15,9 @@ export class BookListComponent { computation: books => books[0] }); + // this also works (shorthand version) + // firstBook = linkedSignal(() => this.books()[0]); + overrideFirstBook() { // Manually updating `firstBook`, which now returns 'jQuery' this.firstBook.set('jQuery'); diff --git a/src/app/books/book/book.component.ts b/src/app/books/book/book.component.ts index 2886a1a..4f56f77 100644 --- a/src/app/books/book/book.component.ts +++ b/src/app/books/book/book.component.ts @@ -20,7 +20,6 @@ export class BookComponent { // this also works: // rating = linkedSignal(() => this.book().rating); - doRateUp() { const newRating = this.rating() + 1; this.rating.set(newRating);