I try to pass an array to my child component (macroNutriments) and iterate it but it's not working, it seems like the array is not passed at all. The other data are displayed though. I'm totaly new to Polymer.
My parent component :
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../macro-aliment/macro-aliment.html">
<dom-module id="macro-aliments">
<template>
<template is="dom-repeat" items="{{aliments}}">
<macro-aliment
nom = '{{item.nom}}'
quantite = '{{item.quantite}}'
image = '{{item.image}}'
macroNutriments = '{{item.macroNutriments}}'
>
</macro-aliment>
</template>
</template>
<script>
Polymer({
is: 'macro-aliments',
ready : function () {
this.aliments = [
{
nom : 'banane',
quantite : '100g',
image : 'images/banane.svg',
macroNutriments : [
{
nom : 'Glucides',
valeur : '13g'
},
{
nom : 'Protéines',
valeur : '25g'
},
{
nom : 'Lipides',
valeur : '10g'
}
]
},
{
nom : 'pomme',
quantite : '1',
image : 'images/pomme.svg',
macroNutriments : [
{
nom : 'Glucides',
valeur : '13g'
},
{
nom : 'Protéines',
valeur : '25g'
},
{
nom : 'Lipides',
valeur : '10g'
}
]
}
]
}
}
);
</script>
</dom-module>
My child component :
<link rel="import" href="../../bower_components/polymer/polymer.html">
<dom-module id="macro-aliment">
<template>
<figure>
<img src="{{image}}" alt="">
<figcaption>
<header>
<h1>{{nom}}</h1>
<span>{{quantite}}</span>
<span>{{macroNutriments}}</span>
</header>
<ul>
<template is="dom-repeat" items="{{macroNutriments}}">
<li>
<span>{{item.valeur}}</span>
<span>{{item.nom}}</span>
</li>
</template>
</ul>
</figcaption>
</figure>
</template>
<script>
Polymer({
is: 'macro-aliment',
properties : {
nom : String,
quantite : String,
image : String,
macroNutriments : Array,
},
});
</script>
</dom-module>
Any ideas ?