0

I want send property model, example i already selected data from table have a model JSON array { a: string, b: object, c:string} but i want to send only property c.

this is my function

public onApprove(mf) {
     if (mf === null || mf.undefined) return;
     if (!this.btnControl) { return; }

     this.btnControl = false;
     let data: Array<string> = [];
     const approvalLeader = new ApprovalL1Model();
     data = mf.data.filter(f => f.isSelector == true);
     data.push(approvalLeader.groupId);

     this.approvalLeaderService.approve(data)
         .subscribe(
             s => {
             },
             e => {
                 this.btnControl = true;
                 this.alertService.error(e.status, e.statusText, e._body);
             });
     this.getData();
     console.log(data);
     this.btnControl = true;
     this.alertService.success('Booking Approved');
}

I already try but my data.push value was undefined, any solution?

1
  • cant you simply loop it & pickup c pass it on server by storing in a new array(temp) Commented Jan 7, 2019 at 7:33

1 Answer 1

1

using rxjs map operator you can acquire that. First of all, collect your object property, after it send it to api. e.g.:

   let array = data.map(object => {return object.c});
Sign up to request clarification or add additional context in comments.

8 Comments

i have a model approvalL1model how to include the model to data.map()?
can i see declaration of approvalModel?
groupId: string; dtoBooking: bookingmodel[];
i mean. this will return undefined your code. because you didn't initialize your object. if you need just groupId you can acquire it with approvalLeader['groupId']
let array = data.map(f => { return approvalLeader['groupID']} ); like this?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.