O'Reilly logo

TypeScript Blueprints by Ivo Gabe de Wolff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Hello World page

To get started with NativeScript, we will first write a simple app. In src/app.ts, we must register mainEntry that will create the view of the app. The entry should be a function that returns a Page. A Page attribute is one of the classes that NativeScript uses for the user interface. We can create a basic page as follows:

import * as application from "application"; 
import { Page } from "ui/page"; 
import { Label } from "ui/label"; 
 
application.mainEntry = () => { 
  const page = new Page(); 
  const label = new Label(); 
  label.text = "Hello, World"; 
  page.content = label; 
  return page; 
}; 
application.start(); 

This will create a single label and add it to the page. The content of the page should be a View class, which is the base ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required