Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5d88535

Browse files
authored
Merge pull request #512 from NativeScript/raikov/router-snippets
Updated router documentation code snippets
2 parents 855e58c + 552b607 commit 5d88535

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import {FirstComponent, SecondComponent} from "./navigation-common";
21
// >> router-config-all
2+
import { FirstComponent, SecondComponent } from "./navigation-common";
3+
34
export const routes = [
4-
{ path: "", redirectTo: "/first", pathMatch: "full",terminal: true },
5+
{ path: "", redirectTo: "/first", pathMatch: "full" },
56
{ path: "first", component: FirstComponent },
6-
{ path: "second", component: SecondComponent },
7+
{ path: "second", component: SecondComponent }
78
];
89
// << router-config-all

‎tests/app/snippets/navigation/config-snippets.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ class GroceryComponent { }
66
class GroceriesApp { }
77

88
// >> router-config
9-
const routes = [
9+
exportconst routes = [
1010
{ path: "login", component: LoginComponent },
1111
{ path: "groceries", component: GroceryListComponent },
12-
{ path: "grocery/:id", component: GroceryComponent },
12+
{ path: "grocery/:id", component: GroceryComponent }
1313
];
1414
// << router-config
1515

@@ -29,7 +29,7 @@ export class GroceriesAppModule {}
2929
// >> router-bootstrap
3030
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
3131
// >> (hide)
32-
function start_snippet() {
32+
function start_snippet() {
3333
// << (hide)
3434
platformNativeScriptDynamic().bootstrapModule(GroceriesAppModule);
3535
// << router-bootstrap
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
// >> router-content-components
2-
import {Component} from '@angular/core';
2+
import {Component} from "@angular/core";
33

44
@Component({
55
selector: "first",
66
template: `
7-
<StackLayout>
8-
<Label text="First component" class="title"></Label>
9-
<Button text="GO TO SECOND" [nsRouterLink]="['/second']" class="link"></Button>
10-
</StackLayout>`
7+
<StackLayout>
8+
<Label text="First component" class="title"></Label>
9+
<Button text="GO TO SECOND" [nsRouterLink]="['/second']" class="link"></Button>
10+
</StackLayout>
11+
`
1112
})
1213
export class FirstComponent { }
1314

1415
@Component({
1516
selector: "second",
1617
template: `
17-
<StackLayout>
18-
<Label text="Second component" class="title"></Label>
19-
<Button text="GO TO FIRST" [nsRouterLink]="['/first']" class="link"></Button>
20-
</StackLayout>`
18+
<StackLayout>
19+
<Label text="Second component" class="title"></Label>
20+
<Button text="GO TO FIRST" [nsRouterLink]="['/first']" class="link"></Button>
21+
</StackLayout>
22+
`
2123
})
2224
export class SecondComponent { }
2325
// << router-content-components

‎tests/app/snippets/navigation/page-outlet.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import {TestApp, registerTestApp} from "../../tests/test-app";
22
import { ApplicationRef } from '@angular/core';
3+
import { Router, NavigationStart, NavigationEnd } from "@angular/router";
34
// >> page-outlet-example
5+
import { platformNativeScriptDynamic, NativeScriptModule } from "nativescript-angular/platform";
46
import { Component, NgModule } from '@angular/core';
5-
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
67
import { NativeScriptRouterModule } from "nativescript-angular/router";
7-
import { Router, NavigationStart, NavigationEnd } from '@angular/router';
88
import { routes } from "./app.routes";
9+
import { FirstComponent, SecondComponent } from "./navigation-common";
910

1011
@Component({
1112
selector: 'page-navigation-test',
1213
template: `<page-router-outlet></page-router-outlet>`
1314
})
14-
export class PageNavigationApp {
15+
export class PageNavigationApp {
1516
// >> (hide)
1617
public startEvent: any;
1718
public endEvent: any;
@@ -38,8 +39,10 @@ export class PageNavigationApp {
3839
}
3940

4041
@NgModule({
42+
declarations: [PageNavigationApp, FirstComponent, SecondComponent],
4143
bootstrap: [PageNavigationApp],
4244
imports: [
45+
NativeScriptModule,
4346
NativeScriptRouterModule,
4447
NativeScriptRouterModule.forRoot(routes)
4548
]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /