In this post , I will give small snippet about passing data parent to child controller.
1
2
3
4
5
6
7
8
9
| //index.js
function goDetail(e){
$.tab.open(Alloy.createController('detail',{data:e.row.title}).getView());
}
$.index.open();
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| //index.xml
<Alloy>
<TabGroup>
<Tab id="tab">
<Window onClick="goDetail" id="win" backgroundColor="white" navBarHidden="true" tabBarHidden="true">
<TableView id="table">
<TableViewRow title="Apple"/>
<TableViewRow title="Bananas"/><br>
<TableViewRow title="Carrots"/>
<TableViewRow title="Potatoes"/>
<TableViewRow title="Cod"/>
<TableViewRow title="Haddock"/><br>
</TableView>
</Window>
</Tab>
</TabGroup>
</Alloy>
|
1
2
3
4
5
6
7
8
9
10
11
| // detail.js
var args = arguments[0] || {};
Ti.API.info(args.data);
$.title.text=args.data;
//detail.xml
<Alloy>
<Window class="container" backgroundColor="white">
<Label top=30 id="title"><Label>
</Window>
</Alloy>
|