I am working in an Angular4 application.In this I am trying to show the API response it displayed as [object object].
lemme explain it .
This is my Json response
This is my service file.
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { HttpClient } from '@angular/common/http';
import { Data } from '@angular/router';
@Injectable()
export class CartdataService {
public i_product_Path = new BehaviorSubject<any>('');
i_cast_Product_Path = this.i_product_Path.asObservable();
current_product :any;
constructor(private http: HttpClient) { }
get_Product_Path(pName: string) {
this.current_product = pName.trim();
this.http.get(`http://localhost:abc/api/data/GetImage/?imageName=${this.current_product}`);
}
}
Here I am calling the API.
This is my Model file.
export interface Images {
big_Images: BImage[];
small_Images: Simage[];
selected_Product_Images: SelectedImage[]
}
export interface BImage {
big_Images: string;
}
export interface Simage {
small_Images: string;
}
export interface SelectedImage {
selected_Product_Image: string;
}
This is my component
import { Component } from '@angular/core';
import { CartdataService } from './cartdata.service';
import { Images } from './model';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
constructor(private CartdataService: CartdataService) {}
images : Images;
ngOnInit() {
this.CartdataService.i_cast_Product_Path.subscribe( (response : Images ) =>
{ this.images = response; });
}
}
Here I am getting the API response ,What I want to do is I need to get display all the API values in a separate tags.
<span >
{{images}}
</span>
By using the above code I got the output as [object object].