i want to bind my api response to my model.ts file but it giving me error

// following is my model.ts

export class Data{
    status:boolean;
    data:statistics[];
}
export class statistics {
    State: string;
    SurveyorName: string;
    NoOfInt: number;
    SampleReceived: number;
    CancelledEntries: number;
    Approved: number;
    DisApproved: number;
}
export class Job{
    name:string;
    position:string;
    salary:number;
}

// following is my api response

objectOfArraySample =
        {
            "status": true,
            "data": {
                "statistics": [
                    {
                        "State": "Karnataka",
                        "SurveyorName": "Keval Kakdiya",
                        "NoOfInt": "2",
                        "SampleReceived": "2",
                        "CancelledEntries": "0",
                        "Approved": "1",
                        "DisApproved": "1"
                    },
                    {
                        "State": "MAHARASHTRA",
                        "SurveyorName": "Keval Kakdiya",
                        "NoOfInt": "0",
                        "SampleReceived": "0",
                        "CancelledEntries": "1",
                        "Approved": "0",
                        "DisApproved": "0"
                    }
                ],
            }
        }

// following is my .ts file

import { Data } from './data.model';
import { Job } from './data.model';

result: Data;
result1: Job[];


 ngOnInit() {
        this.result1 = this.arrayOfObjectSample;
        this.result = this.objectOfArraySample;           // here i am 
assingning value but it give me error
        /*this.result.statistics.push({
            
        })*/
 }


//following error is throwing

Type '{ "status": boolean; "data": { "statistics": { "State": string; 
"SurveyorName": string; "NoOfInt": string; "SampleReceived": string; 
"CancelledEntries": string; "Approved": string; "DisApproved": string; }[]; 
}; }' is not assignable to type 'Data'.
 Types of property 'data' are incompatible.
 Type '{ "statistics": { "State": string; "SurveyorName": string; 
"NoOfInt": string; "SampleReceived": string; "CancelledEntries": string; 
"Approved": string; "DisApproved": string; }[]; }' is missing the following 
properties from type 'statistics[]': length, pop, push, concat, and 26 more.

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/e726a8ac-e2bc-40c8-94c6-1611b8f6aa23%40googlegroups.com.

Reply via email to