Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Angular Services

You're reading from   Angular Services -

Arrow left icon
Product type Paperback
Published in Feb 2017
Publisher Packt
ISBN-13 9781785882616
Length 294 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Sohail Salehi Sohail Salehi
Author Profile Icon Sohail Salehi
Sohail Salehi
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Angular Services
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Setting Up the Environment FREE CHAPTER 2. Introducing Wire-Frames 3. The Collector Service - Using Controllers to Collect Data 4. The Rating Service - Data Management 5. The Notifier Service - Creating Cron Jobs in Angular 6. The Evidence Tree Builder Service - Implementing the Business Logic 7. The Report Generator Service - Creating Controllers to Set Report Template 8. The Accuracy Manager Service - Putting It All Together

Saving objects to the database


Now we can test the Firebase Realtime Database in our project. Let's modify the onChange() method in CollectorComponent and save a new object in the database every time a news items is checked. To do that, first we need to create a parent object in Firebase Realtime Database:

  1. In the Firebase console, select the Sherlock Project and click on Database in the sidebar:

  2. If you move the mouse over the project name, a plus sign appears with add child as tooltip. Click on the plus sign and enter Collector for the Name field. Leave the Value field empty and instead click on the plus sign for the Collector key and add the following values to it. Click the Add button when it is done:

  3. Click the Add button when it is done.

  4. Now open the Collector component, import the AngularFire module, and construct a new AngularFire object as follows:

            // src/app/collector/collector.component.ts 
            //... 
            import {AngularFire, FirebaseObjectObservable} from "angularfire2...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images