Skip to content

Instantly share code, notes, and snippets.

@yadejo
Created April 25, 2016 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yadejo/454c4bd196d56bded35f3a5c09bbf76f to your computer and use it in GitHub Desktop.
Save yadejo/454c4bd196d56bded35f3a5c09bbf76f to your computer and use it in GitHub Desktop.
angular.module('starter.services', [])
.factory('Issues', function($http) {
var baseUrl = "http://localhost:8080/problems/";
// Might use a resource here that returns a JSON array
// Some fake testing data
var issues = [{
id: 0,
name: 'lamp',
room: 'living room',
category: 'electricity',
description: 'lamp gaat niet meer aan, die aan de zetel',
priority: 1,
status: 'broken'
}, {
id: 1,
name: 'faucet',
room: 'kitchen',
category: 'plumbing',
description: 'no warm water',
priority: 2,
status: 'progress'
}];
return {
all: function() {
//return issues;
return $http({
method: 'GET',
url: baseUrl
});
},
remove: function(issues) {
issues.splice(issues.indexOf(issues), 1);
},
get: function(issueId) {
return $http({
method: 'GET',
url: baseUrl + issueId
});
}
};
})
.factory('Rooms', function($http){
var baseUrl = "http://localhost:8080/problems/";
return {
all: function() {
return $http({
method: 'GET',
url: baseUrl
});
}
};
})
.factory('Categories', function($http){
var baseUrl = "http://localhost:8080/categories/";
return {
all: function() {
return $http({
method: 'GET',
url: baseUrl
});
}
};
})
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment