Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the Service #7

Open
web-dave opened this issue Feb 28, 2024 · 1 comment
Open

Use the Service #7

web-dave opened this issue Feb 28, 2024 · 1 comment
Labels

Comments

@web-dave
Copy link
Owner

web-dave commented Feb 28, 2024

  1. Get BoookService into BookList via DI
book-list.component.ts
 service = inject(BookService);
  1. Get All Books
book-list.component.ts
 ...
  books: any[] = [];
  getAllBooks() {
    this.service.getAll().subscribe((data) => (this.books = data));
  }
3. Show all Books
book-list.component.html
 ...
@for (book of books; track $index) {
<div class="book">
  <strong>{{ book.title }}</strong> <br />
  <small>{{ book.subtitle }}</small>
</div>
}
  1. Styling
book-list.component.scss
@import "../../../utils";

.book {
  @include object(100%, 60px, $aqua);
  border-radius: 90px;
  margin-top: 10px;
  padding-left: 45px;
  padding-top: 10px;
}
@web-dave
Copy link
Owner Author

NEXT

@web-dave web-dave added the 25min label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant