Angular Services

Book description

Design state-of-the-art applications with customized Angular services

About This Book

  • Leverage the latest Angular and ES2016 features to create services
  • Integrate third-party libraries effectively and extend your app's functionalities
  • Implement a real-world case study from scratch and level up your Angular skills

Who This Book Is For

If you are a JavaScript developer who is moving on to Angular and have some experience in developing applications, then this book is for you. You need not have any knowledge of on Angular or its services.

What You Will Learn

  • Explore various features and topics involved in modules, services, and dependency injection
  • Sketch and create wire-frames for your project
  • Use controllers to collect data and populate them into NG UIs
  • Create a controller and the required directives to build a tree data structure
  • Implement a logic to decide the relevancy of any given evidence
  • Create a partially-AI service
  • Build controllers to set the template for the report
  • Collect, investigate, perform decision making, and generate reports in one the big automated process

In Detail

A primary concern with modern day applications is that they need to be dynamic, and for that, data access from the server side, data authentication, and security are very important. Angular leverages its services to create such state-of-the-art dynamic applications.

This book will help you create and design customized services, integrate them into your applications, import third-party plugins, and make your apps perform better and faster. This book starts with a basic rundown on how you can create your own Angular development environment compatible with v2 and v4. You will then use Bootstrap and Angular UI components to create pages. You will also understand how to use controllers to collect data and populate them into NG UIs.

Later, you will then create a rating service to evaluate entries and assign a score to them. Next, you will create "cron jobs" in NG. We will then create a crawler service to find all relevant resources regarding a selected headline and generate reports on it. Finally, you will create a service to manage accuracy and provide feedback about troubled areas in the app created.

This book is up to date for the 2.4 release and is compatible with the 4.0 release as well, and it does not have any code based on the beta or release candidates.

Style and approach

This step-by-step tutorial starts by showing how you can create your first Angular services, then customizing it to suit your needs, and finally implementing some real-world case studies on your own to make you confident designing your own application using effective services from scratch.

Table of contents

  1. Angular Services
    1. Angular Services
    2. Credits
    3. About the Author
    4. About the Reviewer
    5. www.PacktPub.com
      1. Why subscribe?
    6. Customer Feedback
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Setting Up the Environment
      1. Introducing Angular
      2. There is no backward compatibility
      3. Previous knowledge of AngularJS 1.x is not necessary
      4. The relationship between ECMAScript, AtScript, and TypeScript
      5. Setting up tools and getting started!
      6. Setting up the seed project
      7. Setting up an Angular project in WebStorm
      8. Frontend developers versus backend developers
      9. Introducing The Sherlock Project
      10. Summary
    9. 2. Introducing Wire-Frames
      1. What is a module?
      2. Components - the reusable objects
      3. The root component
      4. Updating the Bootstrap file
      5. Running the web server
      6. Bootstrapping versus root component
      7. The big picture
      8. The navigation system
      9. The Angular router module
        1. Routing configuration
        2. The navigation bar template
        3. The navigation component
        4. Importing and using the navigation component
      10. The collector wire-frame
        1. The collector component
      11. Accessing a component via root
      12. The rating wire-frame
        1. The rating component
      13. The notifier wire-frame
        1. The notifier component
      14. Updating the navigation system
        1. Single Page Application
      15. Switching to SPA
      16. The Evidence Tree Builder Wire-frame
        1.  The Evidence component
      17. The AI Wire-frame
        1. The AI Component
      18. The Report Generator Wire-frame
      19. The Auto-pilot Wire-frame
      20. The Accuracy Manager Wire-frame
      21. Summary
    10. 3. The Collector Service - Using Controllers to Collect Data
      1. What is a service and why do we need them?
      2. Updating the collector component
      3. The collector service
      4. The Dependency Injection
      5. Property binding
      6. Class binding
      7. Style binding
      8. Event binding
      9. Getting the real news
      10. Angular and observable objects
      11. Updating the collector component
        1. The access control problem
      12. Saving objects in a database
      13. Setting up The Sherlock Project on Firebase
      14. Saving objects to the database
      15. Working with data via lists
      16. Summary
    11. 4. The Rating Service - Data Management
      1. Setting the ranking parameters
      2. The Google Trends service
        1. Obtaining the Trending Keywords
        2. CORS versus JSONP
      3. The rating service structure
      4. The rating logic structure
        1. Implementing the rating logic
        2. Implementing the rating service
      5. The rating component
      6. The rating template
      7. Creating a custom pipe
      8. Summary
    12. 5. The Notifier Service - Creating Cron Jobs in Angular
      1. Cron job versus Interval/Timeout
      2. Introducing node-cron
        1. Dealing with vendors
      3. Getting and rating the news periodically
        1. The Notifier template and business logic
      4. The Notifier component
        1. Two-way data binding
        2. Updating the template
        3. Updating the database
      5. The Notifier service
        1. Checking the rates for collected news
        2. The helper functions
      6. Automating tasks with Zappier
        1. Sending Notification e-mails
      7. In App notifications
      8. News maintenance
      9. Summary
    13. 6. The Evidence Tree Builder Service - Implementing the Business Logic
      1. Clustering and similarity - retrieving documents of interest
      2. The evidence service
      3. The evidence component
        1. Parsing HTML pages into JSON content
      4. The evidence template
        1. Saving all valuable words
        2. Counting the unique words
      5. Understanding the bag of words model
        1. The flaws in the bag of words model
        2. Introducing the TF-IDF factor
        3. Implementing the TF-IDF factor
      6. Corpus - how to build the body
        1. Making the template Corpus aware
        2. Making the component Corpus aware
      7. The Corpus functions
      8. Introducing the Google Custom Search Engine
        1. Enabling the Custom Search API And creating a new CSE
        2. Implementing the corpusBuilder() function
          1. Fetching the links
          2. Creating queries and processing search results
        3. Refactoring the service logic (removing IDF calculations)
        4. Refactoring the template
      9. Updating the component and the service
      10. How to choose a subject for a road test
      11. How can we live On Mars?
        1. Testing the IDF calculations
      12. Getting insights via clustering
        1. Making the template and the component cluster aware
        2. Making the service cluster aware
      13. Data visualization
        1. The modal component
        2. Adding child view to the main component
        3. Creating a network graph for clusters
        4. Adding the network data to the cluster builder
      14. Processing the network graph data
        1. Showing the graph inside the Modal component
          1. Resolving the timing issue
      15. Decorating a network graph
        1. Decorating the edges
        2. Decorating the nodes
          1. The color object
      16. Processing custom events
        1. Final modification on the nodes array
        2. Final thoughts on data visualization
        3. Gathering other types of evidence
        4. Gathering evidence from social networks
      17. Summary
    14. 7. The Report Generator Service - Creating Controllers to Set Report Template
      1. Saving network graph data to the database
      2. The report generator component
        1. The mechanics of component interaction
      3. The report generator template
        1. The configuration parameters
        2. A closer look at the accordion and tab navigations
          1. The right place for holding Firebase objects
      4. Creating new report templates
      5. Updating the report template
        1. How parent component deals with the output data from child component
      6. Deleting The Report Template
      7. Rendering The Reports
        1. Creating new children to render the reports
        2. Creating the report-corpus component
        3. Creating the report-cluster component
        4. Updating the report component
        5. Implementing the report service for the corpus - part one
          1. Updating the views
          2. Optimizing the Firebase performance
        6. Implementing the report service for the Corpus - part two
          1. Updating the Corpus view
        7. Implementing The Report Service For the Clusters
          1. Catching The Phrases
          2. Adding the Conditional Blocks
        8. Updating the parent
      8. Printing the report
      9. Summary
    15. 8. The Accuracy Manager Service - Putting It All Together
      1. Introducing the anatomy of cure and prevention
      2. Why are test frameworks not practical here?
      3. The accuracy manager component
      4. The accuracy manager view
      5. The accuracy service
        1. Implementing the first prevention
        2. Running the code with the prevention mechanism
      6. Summary

Product information

  • Title: Angular Services
  • Author(s): Sohail Salehi
  • Release date: February 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781785882616