我有一个关于Angular 5 httpClient的问题.
这是一个带有方法foo()的模型类,我希望从服务器接收
export class MyClass implements Deserializable{
id: number;
title: string;
deserialize(input: any) {
Object.assign(this, input);
return this;
}
foo(): string {
// return "some string conversion" with this.title
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的服务请求:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { MyClass } from './MyClass';
@Injectable({
providedIn: 'root',
})
export class MyClassService {
constructor(private http: HttpClient) {
}
getMyStuff(): Observable<MyClass[]> {
// this is where I hope …Run Code Online (Sandbox Code Playgroud)