Alright, so there’s again that moment when a complete, minimal reproduction would have helped immensely. Let me just point it out that it’s something you need to supply to save our time trying to help you. Here’s what a really good one looks like:
<App>
<Router ux:Name="router" />
<JavaScript>
var param = {
data: [
{"ass":"36","course_title":"COM 111","exam":"50","id":"1","matric_no":"2014235020035","semester":"first","total_score":"86","unit":"2"},
{"ass":"30","course_title":"COM 131","exam":"48","id":"2","matric_no":"2014235020035","semester":"first","total_score":"78","unit":"3"},
{"ass":"20","course_title":"COM 112","exam":"50","id":"3","matric_no":"2014235020035","semester":"first","total_score":"70","unit":"3"}
]
};
function openPageTwo() {
router.push("second", param);
}
module.exports = {
param: param,
openPageTwo: openPageTwo
};
</JavaScript>
<Navigator DefaultPath="first">
<Panel ux:Template="first">
<Panel Alignment="Center" Width="240" Height="56" Clicked="{openPageTwo}">
<Text Value="Open page two" Color="#fff" Alignment="Center" />
<Rectangle Color="#18f" CornerRadius="2" />
</Panel>
</Panel>
<SecondPage ux:Template="second" />
</Navigator>
<Panel ux:Class="SecondPage">
<JavaScript>
var arr = this.Parameter.map(function(x) {
return x.data;
}).expand();
module.exports = {
arr: arr
};
</JavaScript>
<ScrollView>
<StackPanel>
<Each Items="{arr}">
<StackPanel>
<Text FontSize="25" Value="{course_title}"/>
<Text Color="Black" FontSize="15" Value="{semester}"/>
<Text Color="Black" FontSize="15" Value="{exam}"/>
<Text Color="Black" FontSize="15" Value="{total_score}"/>
</StackPanel>
</Each>
</StackPanel>
</ScrollView>
</Panel>
</App>
Oh, and it shows what the problem was, and how it was solved:
var arr = this.Parameter.map(function(x) {
return x.data;
}).expand();
Since the data
is an array, and it gets encapsulated inside of an Observable, you ended up getting an array stored in the .value
(0th element of the list) of that arr
Observable. And since Each
expects to receive a proper Observable list, not a single-value Observable that has an array in its .value
, it doesn’t really have anything to iterate over.
Chaining .expand()
to the end there makes sure that the inner array is turned into this proper Observable list, just as explained in docs.