The Polymer library is great! But sometimes you're in need of an array while having only field variables. This Polymer Element will help.
Description
The Array-Composer is a Polymer element which combines up to 10 data fields to a one-dimensional array you can use in further data binding. So if you're in need of an array for a binding, just use this element to create one.
Source
The Array-Composer project is hosted on GitHub.
Install package
You can install the package from Bower.io and add this element to your project:
$ bower install array-composer
To use the bower command, you'll need some dev tools first:
Install both and then run this command to install bower to the global node cache:
$ npm install -g bower
See the offical bower help for more details.
Demo
Find the complete demo source here: Demo on GitHub
There are three variables: field0, field1, field2
To create an array from these variables use the following code:
<array-composer array="{{inputArray}}" length="3" f0="[[field0]]" f1="[[field1]]" f2="[[field2]]"></array-composer>
You can then use the inputArray
variable in further bindings, like this:
<template is="dom-repeat" items="{{inputArray}}">
<div>[[item]]</div>
</template>