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(() => null); } getPosts() { return this.$http.get('api/posts') .then(result => result.data); } } RestDataService.$inject = ['$http']; angular.module('app').service('dataService', RestDataService);