Question: import { Injectable } from '@angular/core'; import { Books } from 'src/assets/data/book.interface'; @Injectable({ providedIn: 'root' }) export class BooksService { ______(Q1)___________________; constructor() { } addToReadingList(book:Books)
| import { Injectable } from '@angular/core'; import { Books } from 'src/assets/data/book.interface'; @Injectable({ providedIn: 'root' }) export class BooksService { ______(Q1)___________________; constructor() { } addToReadingList(book:Books) { this.readingBooks.push(book); } getReadingList() { ______(Q2 )___________________; } }
|
- Two methods addToReadingList() and getReadingList() are created in the service file books.service.ts. They are used to add a book to the reading list, and to get all books in the reading list respectively. Which of the following codes should be used to fill in the blank at (Q21)?
- private books: books[ ];
- private readingBooks: Books;
- private readingBooks: Books{ };
- private readingBooks: Books[ ]=[ ];
2. Which of the following codes should be used to fill in the blank at (Q22)?
- return this.readingBooks.push();
- return this.readingBooks.splice();
- return this.readingBooks.slice();
- return this.readingBooks.display();
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
