mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-13 06:13:03 -05:00
fix(test): move all test apps
This commit is contained in:
32
apps/testing/router-outlet/src/app/shelf.component.ts
Normal file
32
apps/testing/router-outlet/src/app/shelf.component.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { AsyncPipe, JsonPipe, NgFor } from '@angular/common';
|
||||
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { map } from 'rxjs';
|
||||
import { availableBooks } from './book.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shelf',
|
||||
standalone: true,
|
||||
imports: [AsyncPipe, JsonPipe, NgFor],
|
||||
template: `
|
||||
<ul>
|
||||
<li *ngFor="let book of books | async">
|
||||
Borrowed Book: {{ book.name }} by {{ book.author }}
|
||||
</li>
|
||||
</ul>
|
||||
`,
|
||||
styles: [],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export default class ShelfComponent {
|
||||
readonly books = inject(ActivatedRoute).queryParams.pipe(
|
||||
map((params) => params?.['book'].toLowerCase()),
|
||||
map((param) =>
|
||||
availableBooks.filter(
|
||||
(b) =>
|
||||
b.name.toLowerCase().includes(param) ||
|
||||
b.author.toLowerCase().includes(param)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user