Copyright © 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: February 2017
Production reference: 1200217
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78588-261-6
www.packtpub.com
Sohail Salehi is a veteran developer who recently decided to become a data scientist. He believes when you look at a programming challenge from a data scientist perspective, things started to change slightly and what used to be the ultimate solution, somehow morphs into a stepping stone for what really matters--data.
He won't lay down some tests and codes as soon as a programming challenge is handed to him, rather he has started to think WHY do we need to gather data, WHAT potential value is hidden inside this data and HOW to convert this potential into value that will make business thrive.
Although he has written a couple of other programming books before, The Sherlock Project is his first attempt to look at the programming challenge from a different perspective. This story is about discovering hidden values inside data and it is the project that he discusses in this book, Angular Services. In the past decade, he worked on some interesting projects with teams of bright developers. But challenges such as handling the traffic for a national newspaper website (NZ Herald) or creating a new game for Lotto (Lotto - 2nd Chance) are not attractive to him anymore. After he got his first certificate in Machine Learning from University of Washington, he decided to combine his development skills with new concepts that he is discovering in his new professional life and provide creative solutions for daily data-related challenges.
Technical concepts are not his only passion. He is an avid traveler and an adventurous surfer. Currently he lives in Bali, where the big waves are roaring most of the year, and he benefits from the rich Balinese culture and stunning tropical nature, which brings out the best of himself.
I would like to thank the Packt Publishing team for supporting me and giving me the opportunity to write and publish another book. My special thanks to Samantha Gonsalves, who helped me all the way and patiently directed me to the path and the goals we set for this book whenever I was off track.
Phodal Huang is a developer, creator, and author. He works for ThoughtWorks as a consultant. He currently focuses on IoT and frontend development. He is the author of Design Internet of Things and Growth: Thinking in Full Stack (in publishing) in Chinese.
He is an open source enthusiast, and has created a series of projects in GitHub. After daily work, he likes to reinvent some wheels for fun. He created the application Growth with Ionic 2 and Angular 2, which is about coaching newbies about programming. You can find out more wheels on his GitHub page, http://github.com/phodal.
He loves designing, writing, hacking, traveling, you can also find out more about him on his personal website at http://www.phodal.com.
He has reviewed Learning Internet of Things and Design IoT Projects.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at
www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
[email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
- Fully searchable across every book published by Packt
- Copy and paste, print, and bookmark content
- On demand and accessible via a web browser
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/Angular-Services/dp/1785882619.
If you'd like to join our team of regular reviewers, you can email us at
[email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!
I always had a thing for the less traveled roads and it reflects itself in this book, Angular Services, as well. When it is about showing the power of front-end frameworks, there are tons of tutorials and contents on how to build To-Do list applications, or time trackers, or any other use cases and path ways which has been explored, explained and exhausted excessively.
What I've aimed for in this book is slightly different. Yes, the subject still Angular Services and we learn about all Angular framework features along the way, but the vehicle is a Machine Learning flavored application called 'The Sherlock Project' which explores:
- Reactive eXtension (rx.js) and observable objects
- The importance of a good Model
- The HTTP requests and how Angular Http module or third party libraries handle it
- The 3 way data-binding offered by the modern noSQL database: Firebase Realtime Database
- Data visualization provided by VizJS
What makes this book different is the use of Regression algorithm to explore major news agency outlets and other online resources, in order to get some insight about a news item. Basically we are using Angular Services as a host to several tools and concepts, so they work together and deliver four main tasks:
- collect data
- analyse and organize keywords
- generate reports for items we are interested in
- and finally evaluate the accuracy of the generated reports
Perhaps that is the main reason that unlike other books, we didn't invest much efforts on how pretty our application looks, rather we focused on what it does and how unique it is. The code is open source and you are most welcome to take it to the next level by adding missing bits and pieces and decorating it with all the pretty bells and whistles that a front-end application deserves.
Chapter 1, Setting Up the Environment, tells you about what you need to get a basic Angular project up and running. The WebStorm IDE (offered by JetBrains) is free for non-commercial use and open source project. The official seed project (offered by Angular team) introduced in this chapter contains all the dependencies (Angular, TypeScript, WebPack and so on) plus the basic components to render a simple page.
Chapter 2, The Wire-Frames, demonstrates the road map we are going to explore for the rest of the book. It explains the components we are going to implement for this project and briefly introduces the services we are going to create to deliver the task of each remaining chapters.
Chapter 3, The Collector Service - Using Controllers to Collect Data, describes the basic Angular concepts like Components, data-binding, decorators and so on during implementation an HTTP service for hitting on RSS outputs and gathering some news. This is where Firebase Realtime Database will be introduced as well and we will see how to use it to record JSON objects as database entries.
Chapter 4, The Rating Service - Data Management, introduces the pipes for the first time and implements a sorting pipe for ordering data in a particular way. In this chapter, we will see how to use TypeScript classes not only to implement Components and Services, but also for creating business logic for models as well.
Chapter 5, The Notifier Service - Creating Cron Jobs in Angular, creates the logic for automated tasks. It will demonstrate a data flow which utilizes the services created in the previous chapters for collecting, rating, and storing qualified news in a list ready to be fetched and notified by the application or later via email. We will see how to implement the helper functions for calculating dates, finding out dated items, and keeping the database clean on each automated job cycle, as well.
Chapter 6, The Evidence Tree Builder Service - Imple...