A
A
Archakov Dennis2017-03-16 16:33:48
Angular
Archakov Dennis, 2017-03-16 16:33:48

How to catch input data from each form?

Hello. Give advice. There is a form with data entry about higher education. I can clone this form several times and specify different data in new forms. How to make it so that when you change in one of the created forms, changes are made to the array.
I.e. There is `$scope.payload.educations = [{ name: '', year: '' }]` and this object is rendered in a form with two inputs (name, year).
If I add a new object, a new form is created with empty values.
How to catch the input data from each form and assign it to a specific object?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Drapeza, 2017-03-17
@archakov06

When rendering an array through ng-repeat, the entered data will be applied to the property of the corresponding object anyway.
If you need to send this data to objects other than this array, then add an on-change to each input, passing in the current $index to identify the form.
Even better, for objects in the educations array, add an id property with a truly unique id, and let that id be created on the fly when a new object is added.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question