Skip to content

Instantly share code, notes, and snippets.

@swallentin
Created November 18, 2015 10:37
Show Gist options
  • Save swallentin/29a1fc4ac676072bafea to your computer and use it in GitHub Desktop.
Save swallentin/29a1fc4ac676072bafea to your computer and use it in GitHub Desktop.
Alternative
(function () {
'use strict';
angular.module('topdog', ['ngMaterial', 'topdog.constants'])
.config(function($mdIconProvider, $mdThemingProvider) {
$mdIconProvider
.iconSet('communication', 'img/icons/sets/communication-icons.svg', 24);
$mdThemingProvider.theme('default')
.primaryPalette('red')
.accentPalette('orange');
})
.controller('AppCtrl', function($scope, Profile) {
Profile.me().success(function (profile) {
$scope.profile = profile;
Profile.getPlayerBySteamId(profile.id).success(function(player) {
$scope.player = player;
});
Profile.getPlayerGamesBySteamId(profile.id).success(function (matches) {
$scope.matches = matches;
})
});
});
})();
angular.module('topdog')
.factory('Profile', function ($http, settings, $log) {
$log.log(settings);
var meApiUrl = [settings.endPoints.base, settings.endPoints.me.path].join(''),
playerbySteamIdUrl = [settings.endPoints.base, settings.endPoints.player.base].join('');
return {
me: function () {
return $http.get(meApiUrl, { withCredentials: true})
},
getPlayerBySteamId: function (steamId) {
return $http({
url: playerbySteamIdUrl + steamId,
method: 'GET',
withCredentials: true
});
},
getPlayerGamesBySteamId: function (steamId) {
return $http({
url: playerbySteamIdUrl + steamId + settings.endPoints.player.matches,
method: 'GET',
withCredentials: true
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment