i399exng1ts/app/rest.data.srv.ts

23 lines
557 B
TypeScript

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);