exportlet getAllProjects: Rx.BehaviorSubject<ProjectInfo[]> = new Rx.BehaviorSubject(cacheProject);
@Injectable() exportclassProjectService{
_create: Rx.Observable<Response> = new Rx.Observable(); newProject: Rx.Subject<ProjectInfo> = new Rx.Subject(); _get: Rx.Observable<any> = new Rx.Observable(); res$: Rx.Observable<any> = new Rx.Subject().asObservable();
constructor(public _http: Http, public option: HeaderWithToken) {
//any new value into the newProject will deliver to post and save as create stream //to check the status code in the create stream to close dialog this._create = this.newProject .flatMap( project => { returnthis._http .post( baseURL + "/project", JSON.stringify(project), this.option.Option ); });
//For get all project from DB, will return an array of projectInfo this._get = this._http .get(baseURL + "/project", this.option.Option) .map(res => res.json());