这是我的服务
get(id: string): Observable<PaginaModel> {
return this.http.get<PaginaModel>('api/pagini/get/' + id);
}
模型:
import { LinieModel } from "./linie.model";
export class PaginaModel {
linii: LinieModel[] = [];
}
在这里我怎么称呼它:
ngOnInit() {
this.canvas = document.getElementById('AfisareCanvas') as HTMLCanvasElement;
this.ctx = this.canvas.getContext('2d');
this.service.get('5b9bad0c457b4e1c70af18f8').subscribe(data => {
console.log(data); //here data is string (like using stringify)
console.log(data.linii.length); //undefined error
});
}
我尝试使用JSON.parse但没有用。