In this module, we are going to treat functionality related to expenses. This is going to be the main module used by our users in the frontend application, because here they will add new expenses and store them in MongoDB through our backend API.
The expense service will implement CRUD operations on expenses and one other important feature of it is getting the balance of expenses. In order to create the expense service, we will follow these steps:
Create a file called
public/src/expense/expense.service.js
.Define the main logic of the service:
import { Injectable } from 'angular2/core'; import { Http, Response, Headers } from 'angular2/http'; import { Observable } from 'rxjs/Observable'; import { Subject } from 'rxjs/Subject'; import { BehaviorSubject } from 'rxjs/Subject/BehaviorSubject'; import { AuthHttp } from '../auth/index'; import { contentHeaders, serializeQuery } from '../common/index'; import { Expense } from './expense.model'; @Injectable() export...