var createViewModel = require("./main-view-model").createViewModel;
function onNavigatingTo(args) {
var page = args.object;
page.bindingContext = createViewModel();
}
exports.onNavigatingTo = onNavigatingTo;
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onNavigatingTo">
<StackLayout>
<Label text="Tap the button" class="title" />
<Button text="TAP" tap="{{ onTap }}" />
<Label text="{{ message }}" class="message" textWrap="true" />
</StackLayout>
</Page>
.message {
font-size: 20;
color: #284848;
horizontal-align: center;
margin: 0 20;
text-align: center;
}
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onNavigatingTo">
<StackLayout>
<Label text="Hello world" />
</StackLayout>
</Page>
var pagesModule = require("ui/page");
var labelModule = require("ui/label");
function createPage() {
var label = new labelModule.Label();
label.text = "Hello, world!";
var page = new pagesModule.Page();
page.content = label;
return page;
}
exports.createPage = createPage;
<Label text="Alii nullo quaerente vultus severitate adsimulata" />
var pagesModule = require("ui/page");
var labelModule = require("ui/label");
function createPage() {
var label = new labelModule.Label();
label.text = "Hello, world!";
var page = new pagesModule.Page();
page.content = label;
return page;
}
exports.createPage = createPage;
var pagesModule = require("ui/page");
var labelModule = require("ui/label");
var device = require("platform").device;
function createPage() {
if (device.os === "iOS") {
var label = new UILabel();
label.text = "Hello, world!";
}
var page = new pagesModule.Page();
page.content = label;
return page;
}
exports.createPage = createPage;
> tns create mon-appli
> tns platform add ios
> tns platform add android
> tns run ios --emulator
> tns run android --emulator
. └── sample-Groceries ├── app │ └── ... ├── node_modules │ └── tns-core-modules ├── package.json └── platforms ├── android └── ios
> tns create my-app-name --template the-template-name