Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     var module = angular.module('footballApp', ['ngRoute']);
  3.  
  4.     module.factory('footballersFactory', footballersFactory);
  5.     footballersFactory.$inject = [
  6.         '$http'
  7.     ]
  8.     function footballersFactory($http) {
  9.         return {
  10.             getFootballers: function() {
  11.                 return $http({
  12.                     method: "GET",
  13.                     url: "/footballers"
  14.                 })
  15.             }  
  16.         }
  17.     }
  18. })();
  19.  
  20.  
  21. (function() {
  22.     angular
  23.         .module('footballApp', [])
  24.         .directive('footballersData', footballersData);
  25.  
  26.     footballersData.$inject = [
  27.         'footballersFactory',
  28.         '$scope'
  29.     ];
  30.  
  31.     function footballersData($scope) {
  32.         return {
  33.             restrict: 'E',
  34.             templateUrl: './frontend/templates/footballersData.html',
  35.             link: function() {
  36.                 footballersFactory.getFotballers().success(function(data){
  37.                     $scope.footballers = data;
  38.                     console.log($scope.footballers);
  39.                 })
  40.             }
  41.         };
  42.     }
  43. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement