# Binding to child array

**URL:** https://discourse.aurelia.io/t/binding-to-child-array/4815
**Category:** Best Practices
**Created:** [June 18, 2022, 10:08pm UTC](https://discourse.aurelia.io/t/binding-to-child-array/4815 "2022-06-18T22:08:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sarp](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@sarp](https://discourse.aurelia.io/u/sarp)
#### Post date: [June 18, 2022, 10:08pm UTC](https://discourse.aurelia.io/t/binding-to-child-array/4815/1 "2022-06-18T22:08:23Z")

</div>

Hey everyone,

I am trying to figure out a good way to handle this situation.

I have a ParentElement which displays a list. In the VM, I have `filters = []` which is an array of strings that I use to determine the filters to be applied to the list. I also have a ChildElement, which I use to chose available filters. The ChildElement’s VM has `@bindable filters = []` and I use two-way binding between the parent’s and child’s `filters` arrays.

My problem is that, sometimes I want to modify the filters like clear the items, remove a single element from the middle or assign the content of another array to filters. However, if I use approaches like `filters = [...anotherArray]` or `filters = []` or `filters = filters.filter(...)` I realize that the connection between the child filters and parent filters disappears. I believe it is because the reference to the original array is lost with the above-mentioned operations. What I want to know is, is there a preferred way to handle such situations? Should I just switch to event handlers? Is my approach fundamentally incorrect?

Any tips and pointers are appreciated.

---

<div class="post-metadata">

### Author: ![ormasoftchile](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/ormasoftchile/32/340_2.png) [@ormasoftchile](https://discourse.aurelia.io/u/ormasoftchile)
#### Post date: [June 19, 2022, 12:28am UTC](https://discourse.aurelia.io/t/binding-to-child-array/4815/2 "2022-06-19T00:28:12Z")

</div>

Regarding the filters, if you want to clear them, you could do

```auto
filters.splice(0, filters.length)

```

If you want to replace them with the contents of another array, this could work:

```auto
filters.splice(0, filters.length, ...anotherArray)

```

In both cases, the reference to the filters bindable is preserved.

Regards.
