E
E
elsa2019-06-01 01:07:10
Angular
elsa, 2019-06-01 01:07:10

How can I process all inputs in Angular2+ with one function?

<div>
    {{product.title}}
    <input class="form-control" type="text" [(ngModel)]="product_title">
    <button class="btn btn-secondary" (click)="editItem(product.id)">Edit</button>
</div>

<div>
    Artikul: {{product.artikul}}
    <input class="form-control" type="text" [(ngModel)]="product_artikul">
    <button class="btn btn-secondary" (click)="editItem(product.id)">Edit</button>
</div>

<div>
    Price: {{product.price}}
    <input class="form-control" type="text" [(ngModel)]="product_price">
    <button class="btn btn-secondary" (click)="editItem(product.id)">Edit</button>
</div>

You need to be able to edit each input with one function (so as not to write a separate function for each input). Please tell me how can I do this, or how to do it in another way.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question