# Accessing current array object within Each, to pass to a Class

**URL:** <https://forums.fusetools.com/t/accessing-current-array-object-within-each-to-pass-to-a-class/6457>\
**Category:** How-to Discussions\
**Created:** [June 22, 2017, 8:09am UTC](https://forums.fusetools.com/t/accessing-current-array-object-within-each-to-pass-to-a-class/6457 "2017-06-22T08:09:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erlend\_Falch-Pederse](https://avatars.discourse-cdn.com/v4/letter/e/4bbf92/32.png) [@Erlend\_Falch-Pederse](https://forums.fusetools.com/u/Erlend_Falch-Pederse)\
**Post date:** [June 22, 2017, 8:09am UTC](https://forums.fusetools.com/t/accessing-current-array-object-within-each-to-pass-to-a-class/6457/1 "2017-06-22T08:09:37Z")

</div>

Sorry, I am guessing this has a very simple answer, but I am just not able to empiric nor google my way out of the problem…

How can I access the current array element, instead of its “properties”, so that I do not need to explicit pass all of the array objects properties to a component class?  
I.e (mockup, may contain compile errors, just to show):

```auto
<JavaScript>
	var ArrayOfActions = [
		{label: "Add", description: "Add some action"},
		{label: "Delete", description: "Delete some action"}
	];
</JavaScript>

<Panel ux:Class="MyButton">	
	<object ux:Property="MyAction"/>		
	<JavaScript>
	       	var localMyAction= this.MyAction.inner();
    	</JavaScript>
	<Button Value="{localMyAction.label}" />
</Panel>

<Each Items="{ArrayOfActions}">
	<MyButton MyAction="{OBJECT???}" />
</Each>

```

I assume the local javascript in class MyButton is also necessary, according to how I interpret Class-documentation.

Any support would be very much appretiated!

---

<div class="post-metadata">

**Author:** ![Erlend\_Falch-Pederse](https://avatars.discourse-cdn.com/v4/letter/e/4bbf92/32.png) [@Erlend\_Falch-Pederse](https://forums.fusetools.com/u/Erlend_Falch-Pederse)\
**Post date:** [June 22, 2017, 8:17am UTC](https://forums.fusetools.com/t/accessing-current-array-object-within-each-to-pass-to-a-class/6457/2 "2017-06-22T08:17:10Z")

</div>

-

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [June 22, 2017, 10:21am UTC](https://forums.fusetools.com/t/accessing-current-array-object-within-each-to-pass-to-a-class/6457/3 "2017-06-22T10:21:11Z")

</div>

Hi Erland,

your custom component implicitly receives the data context of that iterated item. You don’t need to _pass_ anything. Also, no special local JavaScript viewmodel is necessary (but you can have one if you like).

So then, you can just use `{label}` and `{description}` directly, also when inside of your component.

---

<div class="post-metadata">

**Author:** ![Erlend\_Falch-Pederse](https://avatars.discourse-cdn.com/v4/letter/e/4bbf92/32.png) [@Erlend\_Falch-Pederse](https://forums.fusetools.com/u/Erlend_Falch-Pederse)\
**Post date:** [June 22, 2017, 10:28am UTC](https://forums.fusetools.com/t/accessing-current-array-object-within-each-to-pass-to-a-class/6457/4 "2017-06-22T10:28:55Z")

</div>

Geesh, I knew I was going to feel stupid about the answer…

Thanks a bunch! Made things so much cleaner.
