Skip to content

Instantly share code, notes, and snippets.

@gabouh
Last active March 23, 2016 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabouh/d64c07222cbae513caee to your computer and use it in GitHub Desktop.
Save gabouh/d64c07222cbae513caee to your computer and use it in GitHub Desktop.
Get Item element text and use it as title in the next page
var scrollView = new scrollViewModule.ScrollView();
var myItems = [
{ name: "Different Item One" },
{ name: "Different Item Two" }
];
var bindingContext;
exports.loaded = function(args) {
var page = args.object;
bindingContext = page.navigationContext;
console.log('bindingContext');
console.dir(bindingContext);
var topmost = frameModule.topmost().navigatingTo;
console.log('topmost');
console.log(topmost);
// console.log('bindingContextACAAA');
// var title = bindingContext.title;
// console.log(title);
page.bindingContext = { bindingContext,scrollView,myItems:myItems };
};
<page loaded="loaded" xmlns="http://schemas.nativescript.org/tns.xsd">
<Page.actionBar>
<ActionBar title="{{ bindingContext.title }}">
<ActionBar.titleView>
<GridLayout>
<Label text="{{ bindingContext.title }}" horizontalAlignment="center" />
</GridLayout>
</ActionBar.titleView>
</ActionBar>
</Page.actionBar>
</page>
var Observable = require('data/observable');
var bindingContext = new Observable.Observable({
title: 'Home'
});
exports.loaded = function(args) {
var page = args.object;
page.bindingContext = bindingContext;
};
function itemTap(args) {
var item = args.view.bindingContext;
var topmost = frameModule.topmost();
// console.dir(args);
console.dir(item);
bindingContext.title = 'Item One';
// console.dir(item);
// console.log(topmost);
topmost.navigate({
moduleName: 'views/categories/categories',
context: item
});
}
exports.itemTap = itemTap;
<page loaded="loaded" xmlns="http://schemas.nativescript.org/tns.xsd">
<StackLayout class="buttonBox" tap="itemTap">
<Label class="iconSym" text="&#x260e;" />
<Label class="" text="Nav Item One" />
</StackLayout>
<StackLayout class="buttonBox" tap="itemTap">
<Label class="iconSym" text="&#x260e;"/>
<Label class="" text="Nav Item Two"/>
</StackLayout>
</page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment