Skip to content

Commit cc320ed

Browse files
committed
feat: have routing by default for new applications
1 parent c525877 commit cc320ed

20 files changed

+553
-738
lines changed

package-lock.json

Lines changed: 490 additions & 512 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NgModule } from '@angular/core';
2+
import { NativeScriptRouterModule } from 'nativescript-angular/router';
3+
import { Routes } from '@angular/router';
4+
5+
import { HomeComponent } from './home/home.component';
6+
7+
const routes: Routes = [
8+
{ path: '', redirectTo: '/home', pathMatch: 'full' },
9+
{ path: 'home', component: HomeComponent },
10+
];
11+
12+
@NgModule({
13+
imports: [NativeScriptRouterModule.forRoot(routes)],
14+
exports: [NativeScriptRouterModule]
15+
})
16+
export class AppRoutingModule { }

src/ng-new/application/_files/__sourcedir__/app.component.ts

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,7 @@ import { Component } from '@angular/core';
22

33
@Component({
44
selector: '<%= prefix %>-root',
5-
template: `<%
6-
if (!minimal) {
7-
if (routing) { %>
8-
<page-router-outlet></page-router-outlet><%
9-
} else { %>
10-
<!--The content below is only a placeholder and can be replaced.-->
11-
<StackLayout<% if (theme) { %> class="p-20"<% } %>>
12-
<Label text="Tap the button"<% if (theme) { %> class="h1 text-center"<% } %>></Label>
13-
<Button text="tap" (tap)="onTap()"<% if (theme) { %> class="btn btn-primary btn-active"<% } %>></Button>
14-
<Label [text]="getMessage()"<% if (theme) { %> class="h2 text-center"<% } %> textWrap="true"></Label>
15-
</StackLayout><%
16-
}
17-
} %>`
5+
template: `<page-router-outlet></page-router-outlet>`
186
})
19-
export class AppComponent {<% if (!minimal && !routing) { %>
20-
private counter = 42;
21-
22-
public getMessage() {
23-
return this.counter > 0 ?
24-
`${this.counter} taps left` :
25-
'Hoorraaay! You unlocked the NativeScript clicker achievement!';
26-
}
27-
28-
public onTap() {
29-
this.counter--;
30-
}
31-
<% } %>
7+
export class AppComponent {
328
}

src/ng-new/application/_files/__sourcedir__/app.module.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
2-
import { NativeScriptModule } from 'nativescript-angular/nativescript.module';<% if (routing) { %>
2+
import { NativeScriptModule } from 'nativescript-angular/nativescript.module';
33
import { AppRoutingModule } from './app-routing.module';
44

5-
import { ItemService } from "./item/item.service";
6-
import { ItemsComponent } from "./item/items.component";
7-
import { ItemDetailComponent } from "./item/item-detail.component";<% } %>
8-
95
import { AppComponent } from './app.component';
6+
import { HomeComponent } from './home/home.component';
107

118
// Uncomment and add to NgModule imports if you need to use two-way binding
129
// import { NativeScriptFormsModule } from "nativescript-angular/forms";
@@ -16,17 +13,13 @@ import { AppComponent } from './app.component';
1613

1714
@NgModule({
1815
declarations: [
19-
AppComponent,<% if (routing) { %>
20-
ItemsComponent,
21-
ItemDetailComponent,<% } %>
16+
AppComponent,
17+
HomeComponent,
2218
],
2319
imports: [
24-
NativeScriptModule,<% if (routing) { %>
25-
AppRoutingModule,<% } %>
26-
],<% if (routing) { %>
27-
providers: [
28-
ItemService,
29-
],<% } %>
20+
NativeScriptModule,
21+
AppRoutingModule,
22+
],
3023
bootstrap: [AppComponent],
3124
schemas: [NO_ERRORS_SCHEMA],
3225
})

src/ng-new/application/_files/__sourcedir__/home/home.component.css

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!--The content below is only a placeholder and can be replaced.-->
2+
<StackLayout<% if (theme) { %> class="p-20"<% } %>>
3+
<Label text="Tap the button"<% if (theme) { %> class="h1 text-center"<% } %>></Label>
4+
<Button text="tap" (tap)="onTap()"<% if (theme) { %> class="btn btn-primary btn-active"<% } %>></Button>
5+
<Label [text]="getMessage()"<% if (theme) { %> class="h2 text-center"<% } %> textWrap="true"></Label>
6+
</StackLayout>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: '<%= prefix %>-home',
5+
templateUrl: './home.component.html',
6+
styleUrls: ['./home.component.css'],
7+
moduleId: module.id,
8+
})
9+
export class HomeComponent implements OnInit {
10+
private counter = 42;
11+
12+
constructor() { }
13+
14+
ngOnInit() {
15+
}
16+
17+
public getMessage() {
18+
return this.counter > 0 ?
19+
`${this.counter} taps left` :
20+
'Hoorraaay! You unlocked the NativeScript clicker achievement!';
21+
}
22+
23+
public onTap() {
24+
this.counter--;
25+
}
26+
}

src/ng-new/application/_files/package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@
1818
"nativescript-angular": "~6.1.0-rc.0",<% if(theme) { %>
1919
"nativescript-theme-core": "~1.0.4",
2020
<% } %>"reflect-metadata": "~0.1.8",
21-
"rxjs": "~6.1.0",
21+
"rxjs": "~6.2.0",
2222
"tns-core-modules": "~4.1.0",
2323
"zone.js": "^0.8.26"
2424
},
2525
"devDependencies": {
26-
"@angular/cli": "6.1.0",
26+
"@angular/cli": "~6.1.0",
2727
"@angular/compiler-cli": "~6.1.0",
28-
"@angular-devkit/core": "0.7.0",
28+
"@angular-devkit/core": "~0.7.0",
2929
"@nativescript/schematics": "~0.2.0",
30-
"babel-traverse": "6.26.0",
31-
"babel-types": "6.26.0",
32-
"babylon": "6.18.0",
33-
"lazy": "1.0.11",
3430
"nativescript-dev-typescript": "~0.7.0",
3531
"typescript": "~2.7.2"
3632
}

src/ng-new/application/_routing-files/__sourcedir__/app-routing.module.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/ng-new/application/_routing-files/__sourcedir__/item/item-detail.component.html

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)