I have a question about sending data to an ember template. I have an array with the data :
var data = [ {
"Coefficients": "Herkomst ouders: Een van de ouders Nederlands en de andere
niet Nederlands",
"Categorie": "Herkomst",
"Name": "Een van de ouders Nederlands en de andere niet Nederlands",
"Gewicht": "-0,08943"
}, {
"Coefficients": "Type huishouden: Eenouderhuishouden",
"Categorie": "Type huishouden",
"Name": "Eenouderhuishouden",
"Gewicht": "0,49608"
}]
I have a lot more data in it with diffrent category's (Categorie). In the same file I have this code :
var data_prepped = [];
for (var i = 0; i < data.length; i++) {
var new_cat = true;
for (var j = 0; j < data_prepped.length; j++) {
if (data_prepped[j].Categorie === data[i].Categorie) {
new_cat = false;
}
}
if (new_cat) {
data_prepped.push({
'Categorie': data[i].Categorie,
'Antwoorden': []
});
}
for (var j = 0; j < data_prepped.length; j++) {
if (data_prepped[j].Categorie === data[i].Categorie) {
data_prepped[j].Antwoorden.push({
'Coefficients': data[i].Coefficients,
'Name': data[i].Name,
'Gewicht': data[i].Gewicht,
});
}
}
}
export default Route.extend({
model() {
return data_prepped;
}
});
In my template file from ember I run this code :
<section class="category">
<h1>Algemeen</h1>
<h5></h5>
<select class="" name="">
<option data-weight="" name="">
</option>
</select>
</section>
This is working for me but it give me back all the data from the array. But I only want just a part of the data for example this category : "Categorie": "Type huishouden". How can I fix this?
Aucun commentaire:
Enregistrer un commentaire