Guest User

Untitled

a guest
Apr 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. addBook() {
  2. this.errorMessage = null;
  3. this.fireService.getBook(this.bookDetails.isbn).subscribe(data => {
  4. console.log('subscribe called');
  5. if (null != data) {
  6. this.dbox.open(DialogBoxComponent, {
  7. data: { title: 'Error', content: 'Book is already present in Library. Select Edit book to modify the details', button: false }
  8. });
  9. this.errorMessage = 'Book is already present in Library. Select Edit book to modify the details';
  10. } else {
  11. this.fireService.addBook(this.bookDetails);
  12. this.dbox.open(DialogBoxComponent, {
  13. data: { title: 'Success', content: 'Book has been Added to Database', button: false }
  14. });
  15. this.router.navigateByUrl('/add-book');
  16. }
  17. });
  18. }
  19.  
  20. getBook(id) {
  21. console.log('called firebase get book');
  22. return this.db.doc(`/books/${id}`).valueChanges();
  23. }
  24.  
  25. called firebase get book
  26. subscribe called
  27. subscribe called
Add Comment
Please, Sign In to add comment