Call a Method From Inside dom-repeat in Polymer

243 views
Skip to first unread message

vishnu...@triassicsolutions.com

unread,
Oct 17, 2016, 1:37:50 AM10/17/16
to Polymer

I'm having this situation where I need to call a method from the dom-repeat. Below is my code.


I have two arrays one is _dataArray = [{

'abcd': 1234

}, {

'efgh': 5678

}]


and _objectArray = ['abcd', 'efgh']


Below is my code


<template is='dom-repeat' items="[[_dataArray]]" as="rowItem">
     <template is='dom-repeat' items="[[_objectArray]]" as="columnItem">
         <span>[[_getColumnItemValue(rowItem, columnItem)]]</span>
     </template>
</template>

and in my _getColumnItemValue method, I want to get the value for an object with key specified by the columnData attribute.

Like rowData[columnData]

_getColumnItemValue: function(rowData, columnData) {
    return rowData[columnData];
}

My problem is the method _getColumnItemValue is not being called. Is there any better way to do achieve this?

Daniel Llewellyn

unread,
Nov 27, 2016, 3:26:59 PM11/27/16
to vishnu...@triassicsolutions.com, Polymer
On Mon, 17 Oct 2016 at 06:37 vishnu.mohan via Polymer <polym...@googlegroups.com> wrote:

My problem is the method _getColumnItemValue is not being called. Is there any better way to do achieve this?

Hi,

I've put a simile of your code into a codepen to show you an example which works: http://codepen.io/diddledan/pen/Mbvqvr. As you can see, the code is very similar/identical to your own and behaves how it should.

Dan. 
Reply all
Reply to author
Forward
0 new messages