Skip to content

Commit 7efddc7

Browse files
author
Alexander Vakrilov
authored
Merge pull request #302 from NativeScript/rc3
Update to RC3 + 3.0.0-alpha.7
2 parents 348a3e0 + a38a2bb commit 7efddc7

File tree

10 files changed

+78
-64
lines changed

10 files changed

+78
-64
lines changed

nativescript-angular/dom-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {ElementSchemaRegistry} from '@angular/compiler';
22
import {SanitizationService} from '@angular/core/src/security';
3-
import {Parse5DomAdapter} from '@angular/platform-server';
3+
import {Parse5DomAdapter} from '@angular/platform-server/src/parse5_adapter';
44
import {setRootDomAdapter} from '@angular/platform-browser/src/dom/dom_adapter';
55
import {Type} from '@angular/core/src/facade/lang';
66
import {rendererLog, rendererError} from "./trace";

nativescript-angular/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
},
1919
"dependencies": {
2020
"nativescript-intl": "^0.0.2",
21-
"@angular/common": "2.0.0-rc.2",
22-
"@angular/compiler": "2.0.0-rc.2",
23-
"@angular/core": "2.0.0-rc.2",
24-
"@angular/platform-browser": "2.0.0-rc.2",
25-
"@angular/platform-browser-dynamic": "2.0.0-rc.2",
26-
"@angular/platform-server": "2.0.0-rc.2",
21+
"@angular/common": "2.0.0-rc.3",
22+
"@angular/compiler": "2.0.0-rc.3",
23+
"@angular/core": "2.0.0-rc.3",
24+
"@angular/platform-browser": "2.0.0-rc.3",
25+
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
26+
"@angular/platform-server": "2.0.0-rc.3",
2727
"@angular/router-deprecated": "2.0.0-rc.2",
28-
"@angular/router": "3.0.0-alpha.6",
28+
"@angular/router": "3.0.0-alpha.7",
2929
"rxjs": "5.0.0-beta.6",
3030
"zone.js": "^0.6.12",
3131
"reflect-metadata": "^0.1.3",

nativescript-angular/router/ns-router-link.ts

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Directive, HostBinding, HostListener, Input} from '@angular/core';
2-
3-
import {Router, ActivatedRoute} from '@angular/router';
2+
import {LocationStrategy} from '@angular/common';
3+
import {Router, ActivatedRoute, UrlTree} from '@angular/router';
44

55
/**
66
* The RouterLink directive lets you link to specific parts of your app.
@@ -27,28 +27,52 @@ import {Router, ActivatedRoute} from '@angular/router';
2727
* instead look in the current component's children for the route.
2828
* And if the segment begins with `../`, the router will go up one level.
2929
*/
30-
@Directive({selector: '[nsRouterLink]'})
30+
@Directive({ selector: '[nsRouterLink]' })
3131
export class NSRouterLink {
32-
@Input() queryParams: {[k: string]: any};
32+
private commands: any[] = [];
33+
@Input() target: string;
34+
@Input() queryParams: { [k: string]: any };
3335
@Input() fragment: string;
3436

35-
private commands: any[] = [];
37+
// the url displayed on the anchor element.
38+
// @HostBinding() href: string;
3639

37-
constructor(private router: Router, private route: ActivatedRoute) {}
40+
urlTree: UrlTree;
41+
42+
/**
43+
* @internal
44+
*/
45+
constructor(
46+
private router: Router, private route: ActivatedRoute,
47+
private locationStrategy: LocationStrategy) { }
3848

3949
@Input("nsRouterLink")
40-
set params(data: any[]|string) {
50+
set params(data: any[] | string) {
4151
if (Array.isArray(data)) {
4252
this.commands = <any>data;
4353
} else {
4454
this.commands = [data];
4555
}
4656
}
4757

58+
ngOnChanges(changes: {}): any { this.updateTargetUrlAndHref(); }
59+
4860
@HostListener("tap")
4961
onTap() {
50-
this.router.navigate(
51-
this.commands,
52-
{relativeTo: this.route, queryParams: this.queryParams, fragment: this.fragment});
62+
console.log("NSRouterLink.onTap(): " + this.urlTree.toString())
63+
if (this.urlTree) {
64+
this.router.navigateByUrl(this.urlTree);
65+
}
66+
}
67+
68+
private updateTargetUrlAndHref(): void {
69+
this.urlTree = this.router.createUrlTree(
70+
this.commands,
71+
{ relativeTo: this.route, queryParams: this.queryParams, fragment: this.fragment });
72+
73+
console.log("URL updated: " + this.urlTree.toString())
74+
// if (this.urlTree) {
75+
// this.href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.urlTree));
76+
// }
5377
}
5478
}

ng-sample/app/examples/router/page-router-outlet-nested-test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { Page } from "ui/page";
1414
<StackLayout>
1515
<Label text="First component" class="title"></Label>
1616
<StackLayout class="nav">
17-
<Button class="link" text="Start" nsRouterLink="/second/1"></Button>
18-
<Button class="link" text="Detail" nsRouterLink="/second/1/detail/3"></Button>
17+
<Button class="link" text="Start" [nsRouterLink]="['second','1']"></Button>
18+
<Button class="link" text="Detail" [nsRouterLink]="['second','1','detail','3']"></Button>
1919
</StackLayout>
2020
</StackLayout>`
2121
})
@@ -43,7 +43,7 @@ class FirstComponent implements OnInit, OnDestroy {
4343
<StackLayout class="master">
4444
<Label text="Master View" class="subtitle"></Label>
4545
46-
<Button *ngFor="let detail of details" [text]="'Detail ' + detail" [nsRouterLink]="['../detail', detail]"></Button>
46+
<Button *ngFor="let detail of details" [text]="'Detail ' + detail" [nsRouterLink]="['detail', detail]"></Button>
4747
</StackLayout>
4848
`
4949
})
@@ -87,7 +87,7 @@ class DetailComponent {
8787
8888
<StackLayout class="nav">
8989
<Button class="link" text="< BACK" (tap)="goBack()"></Button>
90-
<Button class="link" [text]="'Second ' + (nextDepth$ | async) + ' >'" [nsRouterLink]="['../', (nextDepth$ | async)]"></Button>
90+
<Button class="link" [text]="'Second ' + (nextDepth$ | async) + ' >'" [nsRouterLink]="['/second', (nextDepth$ | async)]"></Button>
9191
</StackLayout>
9292
9393
<router-outlet></router-outlet>
@@ -132,14 +132,12 @@ export class PageRouterOutletNestedAppComponent {
132132

133133

134134
const routes: RouterConfig = [
135-
{ path: "/first", component: FirstComponent },
136-
{ path: "/", redirectTo: "/first", terminal: true },
135+
{ path: "", component: FirstComponent },
137136
{
138-
path: "/second/:depth", component: SecondComponent,
137+
path: "second/:depth", component: SecondComponent,
139138
children: [
140-
{ path: "/", redirectTo: "master", terminal: true },
141-
{ path: "/master", component: MasterComponent },
142-
{ path: "/detail/:id", component: DetailComponent }
139+
{ path: "", component: MasterComponent },
140+
{ path: "detail/:id", component: DetailComponent }
143141
]
144142
},
145143
];

ng-sample/app/examples/router/page-router-outlet-test.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class FirstComponent implements OnInit, OnDestroy {
4444
4545
<Button text="BACK" (tap)="goBack()"></Button>
4646
47-
<Button text="First" [nsRouterLink]="['/first']"></Button>
47+
<Button text="First" [nsRouterLink]="['/']"></Button>
4848
<Button text="Third(1)" [nsRouterLink]="['/third', '1' ]"></Button>
4949
<Button text="Third(2)" [nsRouterLink]="['/third', '2' ]"></Button>
5050
</StackLayout>`
@@ -79,7 +79,7 @@ class SecondComponent implements OnInit, OnDestroy {
7979
8080
<Button text="BACK" (tap)="goBack()"></Button>
8181
82-
<Button text="First" [nsRouterLink]="['/first']"></Button>
82+
<Button text="First" [nsRouterLink]="['/']"></Button>
8383
<Button text="Second(1)" [nsRouterLink]="['/second', '1' ]"></Button>
8484
<Button text="Second(2)" [nsRouterLink]="['/second', '2' ]"></Button>
8585
</StackLayout>`
@@ -104,11 +104,6 @@ class ThirdComponent implements OnInit, OnDestroy {
104104
}
105105
}
106106

107-
108-
109-
110-
111-
112107
@Component({
113108
selector: 'navigation-test',
114109
directives: [ROUTER_DIRECTIVES, NS_ROUTER_DIRECTIVES],
@@ -122,12 +117,10 @@ export class PageRouterOutletAppComponent {
122117
}
123118
}
124119

125-
126120
const routes: RouterConfig = [
127-
{ path: "/first", component: FirstComponent },
128-
{ path: "/", redirectTo: "/first", terminal: true },
129-
{ path: "/second/:id", component: SecondComponent },
130-
{ path: "/third/:id", component: ThirdComponent },
121+
{ path: "", component: FirstComponent },
122+
{ path: "second/:id", component: SecondComponent },
123+
{ path: "third/:id", component: ThirdComponent },
131124
];
132125

133126
export const PageRouterOutletRouterProviders = [

ng-sample/app/examples/router/router-outlet-test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class SecondComponent implements OnInit, OnDestroy {
5050
template: `
5151
<StackLayout>
5252
<StackLayout class="nav">
53-
<Button text="First" nsRouterLink="/first"></Button>
53+
<Button text="First" nsRouterLink="/"></Button>
5454
<Button text="Second(1)" nsRouterLink="/second/1"></Button> <!-- Both work -->
5555
<Button text="Second(2)" [nsRouterLink]="['/second', '2' ]"></Button> <!-- Both work -->
5656
</StackLayout>
@@ -64,9 +64,8 @@ export class RouterOutletAppComponent {
6464

6565

6666
const routes: RouterConfig = [
67-
{ path: "/first", component: FirstComponent},
68-
{ path: "/", redirectTo: "/first", terminal: true },
69-
{ path: "/second/:id", component: SecondComponent },
67+
{ path: "", component: FirstComponent},
68+
{ path: "second/:id", component: SecondComponent },
7069
];
7170

7271
export const RouterOutletRouterProviders = [

ng-sample/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
"tns-core-modules": ">=2.0.0 || >=2.1.0-2016 || >=2.0.0-angular-7",
2727
"nativescript-angular": "^0.1.6",
2828
"nativescript-intl": "^0.0.2",
29-
"@angular/common": "2.0.0-rc.2",
30-
"@angular/compiler": "2.0.0-rc.2",
31-
"@angular/core": "2.0.0-rc.2",
32-
"@angular/platform-browser": "2.0.0-rc.2",
33-
"@angular/platform-browser-dynamic": "2.0.0-rc.2",
34-
"@angular/platform-server": "2.0.0-rc.2",
29+
"@angular/common": "2.0.0-rc.3",
30+
"@angular/compiler": "2.0.0-rc.3",
31+
"@angular/core": "2.0.0-rc.3",
32+
"@angular/platform-browser": "2.0.0-rc.3",
33+
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
34+
"@angular/platform-server": "2.0.0-rc.3",
3535
"@angular/router-deprecated": "2.0.0-rc.2",
36-
"@angular/router": "3.0.0-alpha.6",
36+
"@angular/router": "3.0.0-alpha.7",
3737
"rxjs": "5.0.0-beta.6",
3838
"zone.js": "^0.6.12",
3939
"reflect-metadata": "^0.1.3",

tests/app/multi-page-main.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export class MultiPageMain {
2323
}
2424

2525
const routes: RouterConfig = [
26-
{ path: "/first/:id", component: FirstComponent },
27-
{ path: "/", redirectTo: "/first/multi-page", terminal: true },
28-
{ path: "/second/:id", component: SecondComponent },
26+
{ path: "", redirectTo: "first/multi-page", terminal: true },
27+
{ path: "first/:id", component: FirstComponent },
28+
{ path: "second/:id", component: SecondComponent },
2929
];
3030
export const MultiPageRouterProviders = [
3131
nsProvideRouter(routes, { enableTracing: false })

tests/app/single-page-main.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export class SinglePageMain {
2323
}
2424

2525
const routes: RouterConfig = [
26-
{ path: "/first/:id", component: FirstComponent },
27-
{ path: "/", redirectTo: "/first/single-page", terminal: true },
28-
{ path: "/second/:id", component: SecondComponent },
26+
{ path: "", redirectTo: "first/single-page", terminal: true },
27+
{ path: "first/:id", component: FirstComponent },
28+
{ path: "second/:id", component: SecondComponent },
2929
];
3030
export const SinglePageRouterProviders = [
3131
nsProvideRouter(routes, { enableTracing: false })

tests/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
"nativescript-unit-test-runner": "^0.3.3",
3030
"tns-core-modules": ">=2.0.0-angular-7",
3131
"nativescript-angular": "^0.1.6",
32-
"@angular/common": "2.0.0-rc.2",
33-
"@angular/compiler": "2.0.0-rc.2",
34-
"@angular/core": "2.0.0-rc.2",
35-
"@angular/platform-browser": "2.0.0-rc.2",
36-
"@angular/platform-browser-dynamic": "2.0.0-rc.2",
37-
"@angular/platform-server": "2.0.0-rc.2",
32+
"@angular/common": "2.0.0-rc.3",
33+
"@angular/compiler": "2.0.0-rc.3",
34+
"@angular/core": "2.0.0-rc.3",
35+
"@angular/platform-browser": "2.0.0-rc.3",
36+
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
37+
"@angular/platform-server": "2.0.0-rc.3",
3838
"@angular/router-deprecated": "2.0.0-rc.2",
39-
"@angular/router": "3.0.0-alpha.6",
39+
"@angular/router": "3.0.0-alpha.7",
4040
"rxjs": "5.0.0-beta.6",
4141
"zone.js": "^0.6.12",
4242
"reflect-metadata": "^0.1.3",

0 commit comments

Comments
 (0)