The variable is tied to the main scope and is the product index in the current reference. That way
plusOne() knows which product data to alter. See the MainController for a better picture.
Thanks for your help!
I have a follow-up question
$index is supposed to return 0, 1, 2 etc. to reference an object in the products array, right?
How does $index know which array I’m interacting with? What does the dollar sign mean in this context?
This is not AngularJS specific, but something worth giving a read…
It would take a deeper look into Angular internals to explain the $ sign but the bottom line is that it relates to scope and the current app instance. We know that it is an index of, the controller data object, but beyond that one will have to study the mechanics.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.