Can someone explain how $index works here? thanks in advance


#1


#2

ng-click II

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.


#3

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?

Thanks


#4

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.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.