Hi i have a save funtion in my angular app.if save is failed i need to show error message that returning from api.what i tried is..
in my service;
- private handleError(error: Response) {
- return Observable.throw(error.text());
- }
- save(id: any) {
- .map(res => <string[]>res.json())
- .catch(this.handleError);
- }
component.ts:
- save() {
- this.Service.save(this.id)
- .subscribe(response => {
- this.res= response;
- },
- (error) => {
- this.errorMsg = error
- alert(this.errorMsg)
- });
- }
/final output am getting in alert : [{ "Message": null, "ModelState": [{ "Message": "enter valid range, the range is conflicting with range 8.00 and 17.00" }] }]
but i need to show only "enter valid range, the range is conflicting with range 8.00 and 17.00"
can anyone help me?