我正在学习角度5,并且一直在尝试使用.next方法添加data.service.ts:
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable()
export class DataService {
private go = new BehaviorSubject<any>([' First Goal','Second Goal']);
newvar = this.go.asObservable();
constructor() { }
changeGoal(newvar){
this.newvar.next(this.go);
}
}
并且我得到这个错误:“类型'Observable'上不存在属性'next'”]]
我正在学习angular 5,我一直在尝试使用.next方法添加data.service.ts。从'rxjs / ...
使用go.next(),而不是this.newvar.next(),然后
changeGoal(newvar){
this.go.next(value);