Advertisement
Venciity

adsData.js

Jan 29th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. adsApp.factory('adsData', ['$http', function($http){
  4.  
  5.     function getAllAds(){
  6.         $http.get('http://softuni-ads.azurewebsites.net/api/ads')
  7.             .success(function(data) {
  8.                 console.log(data);
  9.                 return data.ads;
  10.             })
  11.             .error(function() {
  12.                 error('Error occurred when get ads');
  13.             }
  14.         );
  15.     };
  16.  
  17.     function getNumItems(){
  18.         $http.get('http://softuni-ads.azurewebsites.net/api/ads')
  19.             .success(function(data) {
  20.                 console.log(data.numItems);
  21.                 return data.numItems;
  22.             })
  23.             .error(function() {
  24.                 error('Error occurred when get numItems');
  25.             }
  26.         );
  27.     };
  28.  
  29.     function getNumPages(){
  30.         $http.get('http://softuni-ads.azurewebsites.net/api/ads')
  31.             .success(function(data) {
  32.                 console.log(data.numPages);
  33.                 return data.numPages;
  34.             })
  35.             .error(function() {
  36.                 error('Error occurred when get numPages');
  37.             }
  38.         );
  39.     };
  40.  
  41.     return {
  42.         getAllAds: getAllAds,
  43.         getNumItems: getNumItems,
  44.         getNumPages: getNumPages
  45.     }
  46.  
  47. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement