Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 未执行另一主题订阅的流_Angular_Rxjs5 - Fatal编程技术网

Angular 未执行另一主题订阅的流

Angular 未执行另一主题订阅的流,angular,rxjs5,Angular,Rxjs5,代码如下: @Injectable() export class ProjectService { create$: Rx.Subject<Response> = new Rx.Subject(); _create: Rx.Observable<Response> = this.create$.asObservable(); newProject: Rx.Subject<ProjectInfo> = new Rx.Subject(); get$

代码如下:

@Injectable()
export class ProjectService {
  create$: Rx.Subject<Response> = new Rx.Subject();
  _create: Rx.Observable<Response> = this.create$.asObservable();
  newProject: Rx.Subject<ProjectInfo> = new Rx.Subject();
  get$: Rx.Subject<any> = new Rx.Subject();
  _get: Rx.Observable<any> = this.get$.asObservable();

  constructor(public _http: Http, public option: HeaderWithToken) {
    this._create = this.newProject.flatMap(project => {
      console.log("create",project);
      return this._http.post(baseURL + "/project",
               JSON.stringify(project), this.option.Option);
    });

    this._get = this._http
      .get(baseURL + "/project", this.option.Option)
      .do(x=>{
        console.log("to get",x);
      })
      .map(res => res.json());

    this._create
          .map(x=>x.json())
          .filter(res=>res.status==200)
          .subscribe(this.get$);

    this._get.subscribe(x => {
      console.log("get:", x);
    })
  }

  addProject(project: ProjectInfo) {
    this.newProject.next(project);
  }

  getProject() {
    return this._get;
  }
}
请帮忙

我让它工作

@Injectable()
导出类项目服务{
_创建:Rx.Observable=新Rx.Observable();
新建项目:Rx.Subject=新建Rx.Subject();
_get:Rx.Observable=新的Rx.Observable();
res$:Rx.Observable=新Rx.Subject().asObservable();
构造函数(public\u http:http,public选项:HeaderWithToken){
//新项目中的任何新值都将传递给post并另存为create stream
//在“创建要关闭的流”对话框中检查状态代码
this.\u create=this.newProject
.平面图(
项目=>{
返回此。\u http
.邮政(
baseURL+“/项目”,
JSON.stringify(项目),
这个选项
);
});
this.res$=this.\u创建
.filter(res=>res.status==200)
.flatMap(x=>{
DialogServices.getRef()
.然后(x=>{
x、 处置();
})
把这个还给我;
})
//对于从DB获取所有项目,将返回projectInfo数组
这个。_get=this。_http
.get(baseURL+“/project”,this.option.option)
.map(res=>res.json());
此.res$.subscribe(x=>{
cacheProject=x;
log(“cache”,x,cacheProject);
下一步(cacheProject);
})
}
addProject(项目:ProjectInfo){
this.newProject.next(project);
}
}
    this._create
    .map(x=>x.json())
    .filter(res=>res.status==200)
    .subscribe(this.get$);