Skip to content

Instantly share code, notes, and snippets.

@tjvantoll
Created January 7, 2016 19:38
Show Gist options
  • Select an option

  • Save tjvantoll/376164758c3034511d94 to your computer and use it in GitHub Desktop.

Select an option

Save tjvantoll/376164758c3034511d94 to your computer and use it in GitHub Desktop.
A heavily commented version of the NativeScript/Angular integration bootstrap code
// The Angular dependency injection mechanism depends on this import.
// Read more Angular’s dependency injection at https://angular.io/docs/ts/latest/guide/dependency-injection.html.
import "reflect-metadata";
// Because NativeScript runs in a native mobile app, and not the browser,
// you must use a NativeScript-specific bootsrapping function, which does
// some NativeScript-specific configuration before loading the first
// component.
import {nativeScriptBootstrap} from "nativescript-angular/application";
// This imports the Component decorator from Angular 2 itself. You can read
// more about TypeScript decorators at https://angular.io/docs/ts/latest/guide/dependency-injection.html.
import {Component} from "angular2/core";
// Define a single component. The selector property determines how
// this component can be used in other components. For example, a
// component that imports this component can use <main></main> in its
// template. The template property determines how this component should
// be rendered on the screen. This template contains two NativeScript
// components: a <stack-layout> and a <label>.
@Component({
selector: "main",
template: `
<stack-layout>
<label text="hello world"></label>
</stack-layout>
`
})
// Currently this class is empty for simplicity, but you’ll momentarily
// add your component’s logic here.
class AppComponent {}
// This ties your TypeScript code to the XML file you created earlier.
// Notice how app-page.xml includes a loaded="loaded" attribute. This code
// runs after NativeScript loads app-page.xml.
export function loaded() {
// This bootstraps the Angular application, and renders this component’s
// template on the screen.
nativeScriptBootstrap(AppComponent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment