Skip to content

Commit 6c3a104

Browse files
committed
firstBook = linkedSignal(() => this.books()[0]);
1 parent ef9f87d commit 6c3a104

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/app/books/book-list.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export class BookListComponent {
1515
computation: books => books[0]
1616
});
1717

18+
// this also works (shorthand version)
19+
// firstBook = linkedSignal(() => this.books()[0]);
20+
1821
overrideFirstBook() {
1922
// Manually updating `firstBook`, which now returns 'jQuery'
2023
this.firstBook.set('jQuery');

src/app/books/book/book.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export class BookComponent {
2020
// this also works:
2121
// rating = linkedSignal(() => this.book().rating);
2222

23-
2423
doRateUp() {
2524
const newRating = this.rating() + 1;
2625
this.rating.set(newRating);

0 commit comments

Comments
 (0)