S
S
Sashqa2019-07-16 16:50:56
Angular
Sashqa, 2019-07-16 16:50:56

Passing data from one component to another in angular?

Actually there is a parent component and there is a child.
Some data comes to the parent, which I then display as a sign.
I need to pass the id of this record to the child component when clicking on a row.
Here I display the data

<div class="flex-table">
    <div class="tbody">
    <div class="tr" *ngFor="let item of searchResult" (click)=select(item.IDObekta)>
        <div class="td">{{ item.StrahProdukt.NaimObekta }}</div>
        <div class="td">{{ item.Nomer }}</div>
        <div class="td">{{ item.DataPodpisaniya | date: 'dd-MM-yyyy' }}</div>
    </div>
    </div>
</div>

and include child component
<b2b-acquiring *ngIf="selectContract"></b2b-acquiring>

function to send request
search(contract: any) {
    this.searching = true;
    return this.apollo.query({
        query: searchContractQuery,
        variables: {
            docnumber: contract.value.Nomer
        },
        fetchPolicy: 'network-only'
    }).subscribe(({ data }) => {
      this.searchResult = (data as any).contract.searchContract;
      this.searching = false;
    });
};

Tell me how to implement what you need? When clicking on a certain row, display the id of this row in the console

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Eremin, 2019-07-16
@Sashqa

https://angular.io/api/core/Input

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question