Last active
July 25, 2016 10:33
-
-
Save vakrilov/67224fc1b0d96c1d84d6efd112b91afa to your computer and use it in GitHub Desktop.
Inject Page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this import should be first in order to load some required settings (like globals and reflect-metadata) | |
import {nativeScriptBootstrap} from "nativescript-angular/application"; | |
import {Component} from "@angular/core"; | |
import {RouterConfig} from "@angular/router"; | |
import {NS_ROUTER_DIRECTIVES, nsProvideRouter} from "nativescript-angular/router"; | |
import {Page} from "ui/page"; | |
import {Color} from "color"; | |
@Component({ | |
selector: "my-app", | |
template: "<page-router-outlet></page-router-outlet>", | |
directives: NS_ROUTER_DIRECTIVES | |
}) | |
export class AppComponent { | |
} | |
@Component({ | |
selector: 'first', | |
directives: NS_ROUTER_DIRECTIVES, | |
template: ` | |
<StackLayout> | |
<label text="FIRST PAGE"></label> | |
<Button text="GO" nsRouterLink="/second"></Button> | |
</StackLayout> | |
` | |
}) | |
class FirstComponent { | |
constructor(page: Page) { | |
page.backgroundColor = new Color("lightgreen"); | |
} | |
} | |
@Component({ | |
selector: 'second', | |
directives: NS_ROUTER_DIRECTIVES, | |
template: ` | |
<StackLayout> | |
<Label text="SECOND PAGE"></Label> | |
<Button text="GO" nsRouterLink="/"></Button> | |
</StackLayout> | |
` | |
}) | |
class SecondComponent { | |
constructor(page: Page) { | |
page.backgroundColor = new Color("lightblue"); | |
} | |
} | |
const PageRouterOutletRouterProviders = nsProvideRouter([ | |
{ path: "", component: FirstComponent }, | |
{ path: "second", component: SecondComponent }, | |
], {}); | |
nativeScriptBootstrap(AppComponent, [PageRouterOutletRouterProviders]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"\\":"...", | |
"dependencies": { | |
"@angular/common": "2.0.0-rc.3", | |
"@angular/compiler": "2.0.0-rc.3", | |
"@angular/core": "2.0.0-rc.3", | |
"@angular/http": "2.0.0-rc.3", | |
"@angular/platform-browser": "2.0.0-rc.3", | |
"@angular/platform-browser-dynamic": "2.0.0-rc.3", | |
"@angular/platform-server": "2.0.0-rc.3", | |
"@angular/router": "3.0.0-alpha.7", | |
"@angular/router-deprecated": "2.0.0-rc.2", | |
"nativescript-angular": "0.2.0", | |
"tns-core-modules": "^2.1.0" | |
}, | |
"devDependencies": { | |
"nativescript-dev-typescript": "^0.3.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment