I want to get service API data into component class and manipulate data before sending to html. Below is my component class code,
discountlists:Autodiscount;
filterdata:any;
onChangeCountry(id: string){
if(id == 'none'){
alert("No Code Selected");
}else if(id != null || id != ''){
this.filterdata = this.autopostService.getDiscountSchemesById(id).subscribe(
(data) => this.discountlists = data,
error => this.error = error
);
alert(this.filterdata);
}
}
Here i am storing values in filterdata which is type any and i am getting values from service api as below,
{
"discount_id": "1",
"discount_code": "SAVE20",
"discount_price": "10%",
"start_discount_date": "2019-12-17T00:00:00.000+0000",
"end_discount_date": "2019-12-30T05:10:45.680+0000",
"discount_on_car": true,
"discount_on_part": false,
"discount_on_All": false,
"discount_on_cars": [
"Nissan"
],
"discount_on_parts": [
""
]
}
above value is being cast into a class file discountlists:Autodiscount; I want to perform some operations from above values and then i want to display that value into html. As i am getting values in [object Object] how can i cast this into string?