issues
search
web-dave
/
angular-essentials-workshop
2
stars
0
forks
source link
use BookService
#10
Open
web-dave
opened
2 years ago
web-dave
commented
2 years ago
Generate a
book-list
component with angular-cliI (if not exists!!)
Inject
BookService
into
BookListComponent
(DI)
use
BookService
in ngOnInit
show all Books in a list
web-dave
commented
2 years ago
generate (if not exists!!)
```bash ng g c books/book-list ```
book-list.component.ts
```typescript private bookService = inject(BookService) ngOnInit() { this.bookService.getBooks().subscribe(books => this.books = books); } ```
book-list.component.html
```html
{{book.title}}
```
web-dave
commented
2 years ago
Next
book-list
component with angular-cliI (if not exists!!)BookService
intoBookListComponent
(DI)BookService
in ngOnInit