Skip to content

Commit 2887942

Browse files
committed
Update ng-sample project for NG2 RC6
1 parent 5dd8306 commit 2887942

21 files changed

+86
-81
lines changed

ng-sample/app/app.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { NgModule } from "@angular/core";
1111
import { Router } from "@angular/router";
1212
import { NativeScriptRouterModule } from "nativescript-angular/router";
1313
import { NativeScriptFormsModule } from "nativescript-angular/forms";
14-
import { HTTP_PROVIDERS } from "@angular/http";
14+
import { NativeScriptHttpModule } from "nativescript-angular/http";
1515
import { rendererTraceCategory, routerTraceCategory, listViewTraceCategory } from "nativescript-angular/trace";
1616

1717
import trace = require("trace");
@@ -54,11 +54,13 @@ import { AnimationStatesTest } from "./examples/animation/animation-states-test"
5454
imports: [
5555
NativeScriptModule,
5656
NativeScriptFormsModule,
57+
NativeScriptHttpModule,
5758
NativeScriptRouterModule,
5859
],
5960
exports: [
6061
NativeScriptModule,
6162
NativeScriptFormsModule,
63+
NativeScriptHttpModule,
6264
NativeScriptRouterModule,
6365
],
6466
providers: []
@@ -70,6 +72,10 @@ function makeExampleModule(componentType) {
7072
if (componentType.routes) {
7173
imports.push(NativeScriptRouterModule.forRoot(componentType.routes))
7274
}
75+
let exports: any[] = [];
76+
if (componentType.exports) {
77+
exports = componentType.exports
78+
}
7379
let entries = [];
7480
if (componentType.entries) {
7581
entries = componentType.entries;
@@ -83,8 +89,12 @@ function makeExampleModule(componentType) {
8389
bootstrap: [componentType],
8490
imports: imports,
8591
entryComponents: entries,
86-
declarations: entries,
92+
declarations: [
93+
...entries,
94+
...exports,
95+
],
8796
providers: providers,
97+
exports: exports,
8898
})
8999
class ExampleModuleForComponent {}
90100

@@ -112,7 +122,7 @@ function makeExampleModule(componentType) {
112122
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationStatesTest));
113123
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationNgClassTest));
114124
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationKeyframesTest));
115-
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationEnterLeaveTest));
125+
platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationEnterLeaveTest));
116126

117127
//Livesync test
118128
var cachedUrl: string;
@@ -134,5 +144,5 @@ onAfterLivesync.subscribe((moduleRef) => {
134144
}
135145
});
136146

137-
platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LivesyncApp));
147+
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LivesyncApp));
138148
console.log("APP RESTART");

ng-sample/app/examples/http/http-test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {Component} from '@angular/core';
22
import {Http} from '@angular/http';
3-
import {NS_HTTP_PROVIDERS} from 'nativescript-angular/http';
43
import 'rxjs/add/operator/map';
54

65
/* IMPORTANT
@@ -24,7 +23,6 @@ https://blog.nraboy.com/2015/12/fix-ios-9-app-transport-security-issues-in-nativ
2423
margin-bottom:20;
2524
}`
2625
],
27-
providers: [NS_HTTP_PROVIDERS]
2826
})
2927
export class HttpTest {
3028
public title: string;

ng-sample/app/examples/list/list-test-async.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
22
import * as Rx from 'rxjs/Observable';
3-
import { combineLatestStatic } from 'rxjs/operator/combineLatest';
3+
import { combineLatest } from 'rxjs/operator/combineLatest';
44
import { BehaviorSubject } from "rxjs/BehaviorSubject";
55
import { DataItem, DataService } from "./data.service"
66

@@ -92,7 +92,7 @@ export class ListTestFilterAsync {
9292

9393
constructor(private service: DataService) {
9494
// Create filteredItems$ by combining the service.items$ and filter$
95-
this.filteredItems$ = combineLatestStatic(this.service.items$, this.filter$, (data, filter) => {
95+
this.filteredItems$ = combineLatest(this.service.items$, this.filter$, (data, filter) => {
9696
return filter ? data.filter(v => v.id % 2 === 0) : data;
9797
});
9898
}
@@ -114,4 +114,4 @@ export class ListTestFilterAsync {
114114
public toogleFilter() {
115115
this.filter$.next(!this.filter$.value);
116116
}
117-
}
117+
}

ng-sample/app/examples/list/list-test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export class ItemComponent implements AfterViewChecked, DoCheck {
3636
@Component({
3737
selector: 'list-test',
3838
styleUrls: ['examples/list/styles.css'],
39-
directives: [ItemComponent],
4039
changeDetection: ChangeDetectionStrategy.OnPush,
4140
template: `
4241
<GridLayout rows="auto * auto">
@@ -85,4 +84,8 @@ export class ListTest {
8584
this.counter++;
8685
this.myItems.push(new DataItem(this.counter, "data item " + this.counter));
8786
}
88-
}
87+
88+
public static entries = [
89+
ItemComponent
90+
]
91+
}

ng-sample/app/examples/livesync-test/first/first.component.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ button {
1111

1212
stack-layout {
1313
background-color: lightgreen;
14-
}
14+
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { Component } from "@angular/core";
2-
import { ROUTER_DIRECTIVES } from '@angular/router';
3-
import { NS_ROUTER_DIRECTIVES} from "nativescript-angular/router"
42

53
@Component({
64
selector: "first",
7-
directives: [ROUTER_DIRECTIVES, NS_ROUTER_DIRECTIVES],
85
styleUrls: ["examples/livesync-test/first/first.component.css"],
96
templateUrl: "examples/livesync-test/first/first.component.xml"
107
})
118
export class FirstComponent {
12-
}
9+
}

ng-sample/app/examples/livesync-test/livesync-test-app.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { Component } from "@angular/core";
2-
import { RouterConfig } from '@angular/router';
3-
import { NS_ROUTER_DIRECTIVES, nsProvideRouter} from "nativescript-angular/router"
42

53
import {FirstComponent} from "./first/first.component";
64
import {SecondComponent} from "./second/second.component";

ng-sample/app/examples/livesync-test/second/second.component.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ button {
1111

1212
stack-layout {
1313
background-color: lightblue;
14-
}
14+
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { Component } from "@angular/core";
2-
import { ROUTER_DIRECTIVES } from '@angular/router';
3-
import { NS_ROUTER_DIRECTIVES} from "nativescript-angular/router"
42

53
@Component({
64
selector: "second",
7-
directives: [ROUTER_DIRECTIVES, NS_ROUTER_DIRECTIVES],
85
styleUrls: ["examples/livesync-test/second/second.component.css"],
96
templateUrl: "examples/livesync-test/second/second.component.xml"
107
})
118
export class SecondComponent {
12-
}
9+
}

ng-sample/app/examples/modal/modal-content.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component} from '@angular/core';
1+
import {Component, Input} from '@angular/core';
22
import {ModalDialogParams} from "nativescript-angular/directives/dialogs";
33

44
@Component({
@@ -14,7 +14,7 @@ import {ModalDialogParams} from "nativescript-angular/directives/dialogs";
1414
`
1515
})
1616
export class ModalContent {
17-
public prompt: string;
17+
@Input() public prompt: string;
1818
constructor(private params: ModalDialogParams) {
1919
console.log("ModalContent.constructor: " + JSON.stringify(params))
2020
this.prompt = params.context.promptMsg;

ng-sample/app/examples/modal/modal-test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {ModalContent} from "./modal-content";
55

66
@Component({
77
selector: 'modal-test',
8-
directives: [ModalDialogHost],
9-
providers: [ModalDialogService],
108
template: `
119
<GridLayout rows="*, auto" modal-dialog-host>
1210
<StackLayout verticalAlignment="top" margin="12">
@@ -31,6 +29,14 @@ export class ModalTest {
3129
constructor(private modal: ModalDialogService) {
3230
}
3331

32+
static entries = [
33+
ModalContent
34+
];
35+
36+
static exports = [
37+
ModalContent
38+
];
39+
3440
public showModal(fullscreen: boolean) {
3541
var options: ModalDialogOptions = {
3642
context: { promptMsg: "This is the prompt message!" },

ng-sample/app/examples/renderer-test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {CheckedValueAccessor} from 'nativescript-angular/value-accessors/checked
55

66
@Component({
77
selector: 'templated-component',
8-
directives: [TemplatedComponent],
98
templateUrl: 'title.html'
109
})
1110
export class TemplatedComponent {
@@ -16,7 +15,7 @@ export class TemplatedComponent {
1615
@Directive({
1716
selector: 'Progress',
1817
})
19-
export class ProgressComponent {
18+
export class ProgressDirective {
2019
constructor(private element: ElementRef) {
2120
}
2221

@@ -27,7 +26,6 @@ export class ProgressComponent {
2726

2827
@Component({
2928
selector: 'renderer-test',
30-
directives: [TemplatedComponent, ProgressComponent],
3129
templateUrl: './examples/renderer-test.html'
3230
})
3331
export class RendererTest {
@@ -41,6 +39,14 @@ export class RendererTest {
4139

4240
public testModel = { mydate: new Date() };
4341

42+
static entries = [
43+
TemplatedComponent,
44+
];
45+
46+
static exports = [
47+
ProgressDirective
48+
];
49+
4450
constructor() {
4551
this.buttonText = 'Save...'
4652
this.showDetails = true;

ng-sample/app/examples/router/clear-history-test.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit, OnDestroy, Injectable } from "@angular/core";
2-
import { RouterConfig, ActivatedRoute, Router, ROUTER_DIRECTIVES, CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
2+
import { ActivatedRoute, Router, CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
33
import { Observable } from "rxjs";
4-
import { NS_ROUTER_DIRECTIVES, nsProvideRouter, RouterExtensions, PageRoute} from "nativescript-angular/router";
4+
import { RouterExtensions, PageRoute } from "nativescript-angular/router";
55
import { NSLocationStrategy } from "nativescript-angular/router/ns-location-strategy";
66
import { BehaviorSubject} from "rxjs";
77

@@ -50,7 +50,6 @@ export class LocationLog {
5050

5151
@Component({
5252
selector: "first",
53-
directives: [ROUTER_DIRECTIVES, NS_ROUTER_DIRECTIVES, LocationLog],
5453
templateUrl: "examples/router/clear-history.component.html",
5554
styleUrls: ["examples/router/styles.css"]
5655
})
@@ -63,7 +62,6 @@ class FirstComponent implements OnInit, OnDestroy {
6362

6463
@Component({
6564
selector: "second",
66-
directives: [ROUTER_DIRECTIVES, NS_ROUTER_DIRECTIVES, LocationLog],
6765
templateUrl: "examples/router/clear-history.component.html",
6866
styleUrls: ["examples/router/styles.css"]
6967
})
@@ -76,7 +74,6 @@ class SecondComponent implements OnInit, OnDestroy {
7674

7775
@Component({
7876
selector: "third",
79-
directives: [ROUTER_DIRECTIVES, NS_ROUTER_DIRECTIVES, LocationLog],
8077
templateUrl: "examples/router/clear-history.component.html",
8178
styleUrls: ["examples/router/styles.css"]
8279
})
@@ -89,13 +86,12 @@ class ThirdComponent implements OnInit, OnDestroy {
8986

9087
@Component({
9188
selector: 'navigation-test',
92-
directives: [ROUTER_DIRECTIVES, NS_ROUTER_DIRECTIVES],
9389
providers: [LocationLogService],
9490
template: `<page-router-outlet></page-router-outlet>`
9591
})
9692
export class ClearHistoryAppComponent {
97-
static routes: RouterConfig = [
98-
{ path: "", redirectTo: "/first", terminal: true },
93+
static routes = [
94+
{ path: "", redirectTo: "/first", terminal: true, pathMatch: "full" },
9995
{ path: "first", component: FirstComponent },
10096
{ path: "second", component: SecondComponent },
10197
{ path: "third", component: ThirdComponent },
@@ -105,5 +101,6 @@ export class ClearHistoryAppComponent {
105101
FirstComponent,
106102
SecondComponent,
107103
ThirdComponent,
104+
LocationLog,
108105
]
109106
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit, OnDestroy, Injectable } from "@angular/core";
2-
import { RouterConfig, Router, CanActivate} from '@angular/router';
2+
import { Router, CanActivate} from '@angular/router';
33
import { Observable } from "rxjs";
4-
import { NS_ROUTER_DIRECTIVES, nsProvideRouter, RouterExtensions, PageRoute} from "nativescript-angular/router";
4+
import { RouterExtensions } from "nativescript-angular/router";
55
import { NSLocationStrategy } from "nativescript-angular/router/ns-location-strategy";
66
import { BehaviorSubject} from "rxjs";
77
import * as appSettings from "application-settings"
@@ -116,8 +116,8 @@ class AuthGuard implements CanActivate {
116116
template: `<page-router-outlet></page-router-outlet>`
117117
})
118118
export class LoginAppComponent {
119-
static routes: RouterConfig = [
120-
{ path: "", redirectTo: "/main", terminal: true },
119+
static routes = [
120+
{ path: "", redirectTo: "/main", terminal: true, pathMatch: "full" },
121121
{ path: "main", component: MainComponent, canActivate: [AuthGuard] },
122122
{ path: "login", component: LoginComponent },
123123
]

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { Component, OnInit, OnDestroy } from "@angular/core";
2-
import { RouterConfig, ActivatedRoute, Router, ROUTER_DIRECTIVES, Event } from '@angular/router';
2+
import { ActivatedRoute, Router, Event } from '@angular/router';
33
import { Observable } from "rxjs";
4-
import { NS_ROUTER_DIRECTIVES, nsProvideRouter} from "nativescript-angular/router"
54
import { Location, LocationStrategy} from '@angular/common';
65
import { Page } from "ui/page";
76

87

98
@Component({
109
selector: "first",
1110
styleUrls: ["examples/router/styles.css"],
12-
directives: [ROUTER_DIRECTIVES, NS_ROUTER_DIRECTIVES],
1311
template: `
1412
<StackLayout>
1513
<Label text="First component" class="title"></Label>
@@ -38,7 +36,6 @@ class FirstComponent implements OnInit, OnDestroy {
3836
@Component({
3937
selector: 'master',
4038
styleUrls: ["examples/router/styles.css"],
41-
directives: [NS_ROUTER_DIRECTIVES],
4239
template: `
4340
<StackLayout class="master">
4441
<Label text="Master View" class="subtitle"></Label>
@@ -58,7 +55,6 @@ class MasterComponent {
5855
@Component({
5956
selector: 'detail',
6057
styleUrls: ["examples/router/styles.css"],
61-
directives: [NS_ROUTER_DIRECTIVES],
6258
template: `
6359
<StackLayout class="detail">
6460
<Label text="Detail View" class="subtitle"></Label>
@@ -80,7 +76,6 @@ class DetailComponent {
8076
@Component({
8177
selector: "second",
8278
styleUrls: ["examples/router/styles.css"],
83-
directives: [ROUTER_DIRECTIVES, NS_ROUTER_DIRECTIVES],
8479
template: `
8580
<StackLayout>
8681
<Label [text]="'Second component: ' + (depth$ | async)" class="title"></Label>
@@ -121,11 +116,10 @@ class SecondComponent implements OnInit, OnDestroy {
121116

122117
@Component({
123118
selector: 'navigation-test',
124-
directives: [ROUTER_DIRECTIVES, NS_ROUTER_DIRECTIVES],
125119
template: `<page-router-outlet></page-router-outlet>`
126120
})
127121
export class PageRouterOutletNestedAppComponent {
128-
static routes: RouterConfig = [
122+
static routes = [
129123
{ path: "", component: FirstComponent },
130124
{
131125
path: "second/:depth", component: SecondComponent,

0 commit comments

Comments
 (0)