I am brand new to the Angular world. I have a simple application simply queries a database then displays the data in a table. This is the code from the service to run the query (db.service.ts):
query(): Observable<printerResults[]>{
return this.http.get<printerResults[]>(this.dataURL);
};
The call from my component (Printer-component.ts:
results: printerResults[];
ngOnInit() {
this.getData();
};
getData(): void {
this.TestService.query()
.subscribe((res: printerResults[]) => {this.results = res}, err =>
console.log("error"));
}
And my class declaration (Results.ts):
export class printerResults {
Cell: string;
Plant: string;
PrinterDPI: number;
PrinterName: string;
PrinterType: string;
}
If I put a console.log in the subscribe like:
.subscribe(res => console.log(res), err =>
console.log("error"));
It shows the full object. But when i try to use it on the html side, I get [object Object]. Any help would be appreciated.
res object. Try doingthis.res = resand then in your template do the following{{res | json}}- JSingh