Created
September 8, 2016 22:24
-
-
Save Abdizriel/c170e7579c8d27562743c429d4b2a80c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import angular from 'angular'; | |
import uiRouter from 'angular-ui-router'; | |
import routing from './activities.routes'; | |
import ActivitiesFactory from './activities.service'; | |
export class UserActivitiesController { | |
... | |
/*@ngInject*/ | |
constructor($scope, socket, ActivitiesService) { | |
this.socket = socket; | |
this.currentFilters = this.dateFilter; | |
this.ActivitiesService = ActivitiesService; | |
} | |
$onInit() { | |
console.log(this.ActivitiesService); | |
} | |
... | |
} | |
export default angular.module('sybilApp.user.activities', [uiRouter]) | |
.config(routing) | |
.factory('ActivitiesService', ActivitiesFactory) | |
.component('activities', { | |
template: require('./activities.html'), | |
controller: UserActivitiesController, | |
controllerAs: 'vm' | |
}) | |
.name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* Create a Activity API Service. | |
* @class ActivitiesService | |
* @classdesc Activities API service | |
* @param {Object} $http - Angular service that facilitates communication with the remote HTTP | |
* @returns {Object} services - All Activities sevices | |
*/ | |
export class ActivitiesService { | |
/*@ngInject*/ | |
constructor($http) { | |
this.$http = $http; | |
this.urlBase = '/api/activities'; | |
} | |
/** | |
* @function getAll | |
* @description Get all Activities | |
* @returns {Function|Promise} response - BE response | |
*/ | |
getAll() { | |
return this.$http.get(this.urlBase) | |
} | |
/** | |
* @function getSingle | |
* @description Get single Activity | |
* @param {String|Number} id - Activity ID | |
* @returns {Function|Promise} response - BE response | |
*/ | |
getSingle(id) { | |
return this.$http.get([this.urlBase, id].join('/')); | |
} | |
/** | |
* @function create | |
* @description Create new Activity | |
* @param {Object} activity - Activity parameters | |
* @returns {Function|Promise} response - BE response | |
*/ | |
create(activity) { | |
return this.$http.post(this.urlBase, activity); | |
} | |
/** | |
* @function update | |
* @description Update existing Activity | |
* @param {String|Number} id - Activity ID | |
* @param {Object} activity - Activity parameters | |
* @returns {Function|Promise} response - BE response | |
*/ | |
update(id, activity) { | |
return this.$http.patch([this.urlBase, id].join('/'), activity); | |
} | |
/** | |
* @function destroy | |
* @description Delete Activity | |
* @param {String|Number} id - Activity ID | |
* @returns {Function|Promise} response - BE response | |
*/ | |
destroy(id) { | |
return this.$http.delete([this.urlBase, id].join('/')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment