This repository has been archived by the owner on Aug 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
API
JAG edited this page Oct 25, 2017
·
1 revision
LTW API
Services will only be accessed via angular service in controller.
// Resource Controller
(function() {
'use strict';
// Resources controller
angular
.module('resources')
.controller('ResourcesSearchController', ResourcesSearchController);
ResourcesSearchController.$inject = ['ResourcesService']; // API Service connected
function ResourcesSearchController(resources) { // service name shortened
var vm = this;
resources
.searchResource(query) // search
.get(onSuccess, onFail); // get call for /api/r/search/:query
}
}());
// Resources service used to communicate Resources REST endpoints
(function () {
'use strict';
angular
.module('resources')
.factory('ResourcesService', ResourcesService);
ResourcesService.$inject = ['$resource'];
function ResourcesService($resource) {
var service = {
getResource:getResource,
searchResource:searchResource,
getNew:getNew,
getFeatured:getFeatured
};
return service;
function getResource(id){
return $resource('api/r/'+id);
}
function searchResource(query){
return $resource('api/r/search/'+query);
}
function getNew(){
return $resource('api/r/new');
}
function getFeatured(){
return $resource('api/r/feat');
}
}
}());
/api
Resources
New
/r/new
Featured
/r/feat
Search
/r/search/:query
Featured
/r/search/:query/:page
Categories
All
/c
By Name
/c/:name