Goce Ribeski
Goce Ribeski

Reputation: 1372

Polymer, observer for object property with numeric key

How to observe an object property with numeric key, as:

"employees":[
     {"1": 0, "2":"John", "3":"Doe"}, 
     {"1": 1, "2":"Anna", "3":"Smith"},
]

Observing whole object works well with: employees.*

But can not target specific property as: employees["2"] . How can specific property be targeted?

Here is Plunk example.

Upvotes: 0

Views: 64

Answers (2)

tony19
tony19

Reputation: 138276

To observe all changes to the 2nd employee in your example, you'd use Deep sub-property changes on array items:

observers: [
  'bigup(datatable.employees.#1.*)'
],

plunker

Upvotes: 2

a1626
a1626

Reputation: 2964

In order to have observer on deep property you can mention that property in observer datatable.employees.2. You can read more on it here.

I've also updated plunkr for you

Upvotes: 2

Related Questions