Skip to content

Instantly share code, notes, and snippets.

@jb41
Created February 1, 2017 07:38
Show Gist options
  • Save jb41/98cd172f890745bbd0eacbe0d725b0a2 to your computer and use it in GitHub Desktop.
Save jb41/98cd172f890745bbd0eacbe0d725b0a2 to your computer and use it in GitHub Desktop.
angular.module('app').service('Subjucator', [
'$http', function($http) {
return {
get: function(url) {
return $http.get(url);
},
post: function(url, data) {
return $http.post(url, data);
}
};
}
]);
angular.module('app').controller('HomeCtrl', [
'$scope', 'Subjucator', function($scope, Subjucator) {
$scope.saveToBetaSignUp = function() {
var data;
console.log("saveToBetaSignUp :: Start");
data = {
twitter: $scope.formData.betaSignUp.twitter,
timestamp: currentDate()
};
Subjucator.post($scope.urls.betaSignUpFormUrl, data).success(function(response) {
console.log(response);
return $scope.emailSubscribed = true;
}).error(function(response) {
return console.log(response);
});
return console.log("saveToBetaSignUp :: End");
};
$scope.readUseCases = function() {
console.log("readFromUseCases :: Start");
Subjucator.get($scope.urls.useCasesTextsUrl).success(function(response) {
$scope.useCases = response;
return console.log($scope.useCases);
}).error(function(response) {
return console.log(response);
});
return console.log("readUseCases :: End");
};
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment