如何使用 Angular 6 使用 rxjs 6 显示时钟。下面的代码适用于 angular 5。但现在我收到一条错误消息,说间隔不是 Observable 类型。
@Injectable()
export class MailService {
private clock: Observable<Date>;
constructor(private http : HttpClient) {
this.clock = Observable.interval(1000).map(tick => new Date()).share();
}
getClock(): Observable<Date> {
return this.clock;
}
}
Run Code Online (Sandbox Code Playgroud)