i399exng1ts/app/rest.data.srv.ts

23 lines
557 B
TypeScript
Raw Normal View History

2017-05-17 18:36:09 +03:00
import { Post } from './post.cls';
import { DataService } from './data.srv.i';
import { IHttpService } from 'angular';
export class RestDataService implements DataService {
constructor(private $http: IHttpService) {}
addPost(post: Post) {
return this.$http.post('api/posts', post)
.then(() => <void> null);
}
getPosts() {
return this.$http.get('api/posts')
.then(result => result.data);
}
}
RestDataService.$inject = ['$http'];
angular.module('app').service('dataService', RestDataService);