I have a question about this -
How does the angular understand which $index the list item?
The ng-repeat directive for each repeated element creates its own scope, to which it adds the following utility properties
$ index - number - index of the element to be repeated (0..length-1)
$ first - boolean - true if the first element to be repeated (index == 0).
$ middle - boolean - true if the element is repeated between the first and the last.
$ last - boolean - true if the last element to be repeated is (index == length-1).
$ even - boolean - true if the position of $ index is even (otherwise false).
$ odd - boolean - true if the position of $ index is odd (otherwise false).
Since the functions called from the view, are called in the context of the current scope, and for each element created its own, when you call
remove($index) $index - will be taken from a specific scope and have the correct value.
Source: https://ru.stackoverflow.com/questions/485858/
All Articles