gpt4 book ai didi

typescript - Angular5在项目中导入RxJS时出错

转载 作者:行者123 更新时间:2023-12-04 22:39:57 26 4
gpt4 key购买 nike

找不到可观察的,我该怎么办?我不知道如何在http上使用rxjs。有人可以告诉我吗?

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { IEmployee } from './employee';
import { Observable } from 'rxjs/Observable ';

@Injectable()
export class EmployeeService {

private _url: string = "/assests/data/employee.json";
constructor(private http: HttpClient) { }

getEmployees(): Observable<IEmployee[]>{
return this.http.get<IEmployee[]>(this._url);
}
}

最佳答案

对于rxjs 6,您需要像这样导入Observable:

import { Observable } from 'rxjs';


您可以在这里检查:
https://github.com/ReactiveX/rxjs#installation-and-usage

关于typescript - Angular5在项目中导入RxJS时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50319070/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com