1 / 14

Services

Services. Angular Basics. Table of Contents. What is a service Why using services Custom services Built-in services. What Is a Service. What Is a Service. In Angular service is A worker object Easier use of different aspects of the app Over-the-Wire or not Often stateless.

keira
Download Presentation

Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Services Angular Basics

  2. Table of Contents • What is a service • Why using services • Custom services • Built-in services

  3. What Is a Service

  4. What Is a Service • In Angular service is • A worker object • Easier use of different aspects of the app • Over-the-Wire or not • Often stateless

  5. Why Using Services

  6. Why Using Services • Services are: • Reusable • "SOLID" • Dependency Injection • Testable

  7. Custom Services

  8. Custom Services • Create Custom Services • Inject it in a controller module.factory('serviceName', function (services){ // implement service }); eventsApp.controller('Ctrl', function Ctrl($scope, serviceName) { // use service } );

  9. Built-in Services

  10. Built-in Services • Built-in Services $http – AJAX request $resource – AJAX with restfull services $q – Promise library $anchorScroll – Scrolls to element $cacheFactory – cache service (key-value pair) $compile – compiles element with directives $parse – parses expressions $locale – localization of dates, numbers $timeout – timeout with compiling $exceptionHandler – handling exceptions $filter – access to filter functions $cookieStore – cookie sessions usage

  11. Built-in Services • Other Built-in Services $interpolate – modifies the {{ template $log – logs into the console $rootScope – the "base" scope (avoid using it) $window – the window $document – the document DOM element $rootElement – the root of the app $route – for routes $routeParams – retrieve route parameters $location – parses the URL $httpBackend – fake HTTP (for testing) $controller – instantiates controllers

  12. Angular services Custom services Built-in services Summary

  13. AngularJS http://academy.telerik.com

  14. Update the save method of the artistData service to lookup next artist Id by finding the highest artist id of all existing artist and incrementing by one Create register and login with unique email. Create EditProfile page to save the user profile using a new service called userData. Use a $resource and save them to the url: '/data/user/:userName' Store the user’s albums - up-votes in a cookie and only allow the user to up-vote each session once. *Allow users to log in after storing their user profile and when they up-vote, track their up-votes in their user profile object. Exercises

More Related