【发布时间】:2021-05-30 19:31:51
【问题描述】:
employee.service.ts
import { Injectable } from '@angular/core';
import {Observable} from 'rxjs'
import {HttpClient,HttpClientModule} from'@angular/common/http/http'
import { Employee } from './employee';
@Injectable({
providedIn: 'root'
})
export class EmployeeService {
private apiServerUrl = '';
constructor(private http:HttpClient) { }
public getEmployee(): Observable<Employee[]>{
return this.http.get<Employee[]>(`${this.apiServerUrl}/employee/all);
}
}
员工.ts
export interface Employee{
id:number;
name:string;
email:string;
jobTitle:string;
phone:string;
imageUrl:string;
employeeCode:string;
}
当我尝试返回时
public getEmployee(): Observable<Employee[]>{
return this.http.get<Employee[]>(`${this.apiServerUrl}/employee/all);
}
收到此错误。
类型 'Observable
【问题讨论】: