Skip to content

Commit 9da4fa7

Browse files
committed
feat: Angular 19
1 parent 84fca22 commit 9da4fa7

23 files changed

+168
-171
lines changed

packages/template-blank-ng/package.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"main": "src/main.ts",
44
"displayName": "Blank",
55
"templateType": "App template",
6-
"version": "8.8.2",
6+
"version": "8.8.3",
77
"description": "Blank template for NativeScript apps using Angular",
88
"author": "NativeScript Team <[email protected]>",
99
"license": "Apache-2.0",
@@ -39,26 +39,26 @@
3939
"url": "https://github.com/NativeScript/NativeScript/issues"
4040
},
4141
"dependencies": {
42-
"@angular/animations": "~18.0.0",
43-
"@angular/common": "~18.0.0",
44-
"@angular/compiler": "~18.0.0",
45-
"@angular/core": "~18.0.0",
46-
"@angular/forms": "~18.0.0",
47-
"@angular/platform-browser": "~18.0.0",
48-
"@angular/platform-browser-dynamic": "~18.0.0",
49-
"@angular/router": "~18.0.0",
50-
"@nativescript/angular": "^18.0.0",
42+
"@angular/animations": "~19.0.0",
43+
"@angular/common": "~19.0.0",
44+
"@angular/compiler": "~19.0.0",
45+
"@angular/core": "~19.0.0",
46+
"@angular/forms": "~19.0.0",
47+
"@angular/platform-browser": "~19.0.0",
48+
"@angular/platform-browser-dynamic": "~19.0.0",
49+
"@angular/router": "~19.0.0",
50+
"@nativescript/angular": "^19.0.0",
5151
"@nativescript/core": "~8.8.0",
5252
"@nativescript/theme": "^3.1.0",
5353
"rxjs": "~7.8.0",
54-
"zone.js": "~0.14.0"
54+
"zone.js": "~0.15.0"
5555
},
5656
"devDependencies": {
57-
"@angular-devkit/build-angular": "~18.0.0",
58-
"@angular/compiler-cli": "~18.0.0",
57+
"@angular-devkit/build-angular": "~19.0.0",
58+
"@angular/compiler-cli": "~19.0.0",
5959
"@nativescript/types": "~8.8.0",
6060
"@nativescript/webpack": "~5.0.0",
61-
"@ngtools/webpack": "~18.0.0",
62-
"typescript": "~5.4.0"
61+
"@ngtools/webpack": "~19.0.0",
62+
"typescript": "~5.6.0"
6363
}
6464
}

packages/template-blank-ng/src/app/app-routing.module.ts

-17
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import { Component } from '@angular/core'
1+
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { PageRouterOutlet } from '@nativescript/angular';
23

34
@Component({
45
selector: 'ns-app',
5-
templateUrl: 'app.component.html',
6+
templateUrl: './app.component.html',
7+
imports: [PageRouterOutlet],
8+
schemas: [NO_ERRORS_SCHEMA],
69
})
710
export class AppComponent {}

packages/template-blank-ng/src/app/app.module.ts

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Routes } from '@angular/router';
2+
3+
export const routes: Routes = [
4+
{ path: '', redirectTo: '/home', pathMatch: 'full' },
5+
{ path: 'home', loadComponent: () => import('./home/home.component').then(m => m.HomeComponent) },
6+
];

packages/template-blank-ng/src/app/home/home-routing.module.ts

-13
This file was deleted.

packages/template-blank-ng/src/app/home/home.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
<GridLayout>
66
<!-- Add your page content here -->
7+
<Label text="Hello"></Label>
78
</GridLayout>
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { Component, OnInit } from '@angular/core'
1+
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import {
3+
NativeScriptCommonModule,
4+
NativeScriptRouterModule,
5+
} from '@nativescript/angular';
26

37
@Component({
48
selector: 'Home',
59
templateUrl: './home.component.html',
10+
imports: [NativeScriptCommonModule, NativeScriptRouterModule],
11+
schemas: [NO_ERRORS_SCHEMA],
612
})
7-
export class HomeComponent implements OnInit {
8-
constructor() {
9-
// Use the component constructor to inject providers.
10-
}
13+
export class HomeComponent {
1114

12-
ngOnInit(): void {
13-
// Init your component properties here.
14-
}
1515
}

packages/template-blank-ng/src/app/home/home.module.ts

-12
This file was deleted.

packages/template-blank-ng/src/main.ts

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
1-
import { platformNativeScript, runNativeScriptAngularApp } from '@nativescript/angular';
1+
import {
2+
bootstrapApplication,
3+
provideNativeScriptHttpClient,
4+
provideNativeScriptNgZone,
5+
provideNativeScriptRouter,
6+
runNativeScriptAngularApp,
7+
} from '@nativescript/angular';
8+
import { provideExperimentalZonelessChangeDetection } from '@angular/core';
9+
import { withInterceptorsFromDi } from '@angular/common/http';
10+
import { routes } from './app/app.routes';
11+
import { AppComponent } from './app/app.component';
212

3-
import { AppModule } from './app/app.module';
13+
/**
14+
* Disable zone by setting this to true
15+
* Then also adjust polyfills.ts (see note there)
16+
*/
17+
const EXPERIMENTAL_ZONELESS = false;
418

519
runNativeScriptAngularApp({
6-
appModuleBootstrap: () => platformNativeScript().bootstrapModule(AppModule),
20+
appModuleBootstrap: () => {
21+
return bootstrapApplication(AppComponent, {
22+
providers: [
23+
provideNativeScriptHttpClient(withInterceptorsFromDi()),
24+
provideNativeScriptRouter(routes),
25+
EXPERIMENTAL_ZONELESS
26+
? provideExperimentalZonelessChangeDetection()
27+
: provideNativeScriptNgZone(),
28+
],
29+
});
30+
},
731
});
8-

packages/template-blank-ng/src/polyfills.ts

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import '@nativescript/core/globals';
77
// Install @nativescript/angular specific polyfills
88
import '@nativescript/angular/polyfills';
99

10+
/**
11+
* Disable zone completely by removing the following 3 imports
12+
* alongside also adjusting main.ts to boot zoneless
13+
*/
14+
1015
/**
1116
* Zone.js and patches
1217
*/

packages/template-hello-world-ng/package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nativescript/template-hello-world-ng",
33
"main": "./src/main.ts",
4-
"version": "8.8.2",
4+
"version": "8.8.3",
55
"author": "NativeScript Team <[email protected]>",
66
"description": "NativeScript Angular Hello World template",
77
"license": "Apache-2.0",
@@ -33,26 +33,26 @@
3333
"url": "https://github.com/NativeScript/NativeScript/issues"
3434
},
3535
"dependencies": {
36-
"@angular/animations": "~18.0.0",
37-
"@angular/common": "~18.0.0",
38-
"@angular/compiler": "~18.0.0",
39-
"@angular/core": "~18.0.0",
40-
"@angular/forms": "~18.0.0",
41-
"@angular/platform-browser": "~18.0.0",
42-
"@angular/platform-browser-dynamic": "~18.0.0",
43-
"@angular/router": "~18.0.0",
44-
"@nativescript/angular": "^18.0.0",
36+
"@angular/animations": "~19.0.0",
37+
"@angular/common": "~19.0.0",
38+
"@angular/compiler": "~19.0.0",
39+
"@angular/core": "~19.0.0",
40+
"@angular/forms": "~19.0.0",
41+
"@angular/platform-browser": "~19.0.0",
42+
"@angular/platform-browser-dynamic": "~19.0.0",
43+
"@angular/router": "~19.0.0",
44+
"@nativescript/angular": "^19.0.0",
4545
"@nativescript/core": "~8.8.0",
4646
"@nativescript/theme": "^3.1.0",
4747
"rxjs": "~7.8.0",
48-
"zone.js": "~0.14.0"
48+
"zone.js": "~0.15.0"
4949
},
5050
"devDependencies": {
51-
"@angular-devkit/build-angular": "~18.0.0",
52-
"@angular/compiler-cli": "~18.0.0",
51+
"@angular-devkit/build-angular": "~19.0.0",
52+
"@angular/compiler-cli": "~19.0.0",
5353
"@nativescript/types": "~8.8.0",
5454
"@nativescript/webpack": "~5.0.0",
55-
"@ngtools/webpack": "~18.0.0",
55+
"@ngtools/webpack": "~19.0.0",
5656
"typescript": "~5.4.0"
5757
}
5858
}

packages/template-hello-world-ng/src/app/app-routing.module.ts

-18
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import { Component } from '@angular/core'
1+
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { PageRouterOutlet } from '@nativescript/angular';
23

34
@Component({
45
selector: 'ns-app',
56
templateUrl: './app.component.html',
7+
imports: [PageRouterOutlet],
8+
schemas: [NO_ERRORS_SCHEMA],
69
})
710
export class AppComponent {}

packages/template-hello-world-ng/src/app/app.module.ts

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Routes } from '@angular/router';
2+
import { ItemsComponent } from './item/items.component';
3+
import { ItemDetailComponent } from './item/item-detail.component';
4+
5+
export const routes: Routes = [
6+
{ path: '', redirectTo: '/items', pathMatch: 'full' },
7+
{ path: 'items', component: ItemsComponent },
8+
{ path: 'item/:id', component: ItemDetailComponent },
9+
];
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<ActionBar title="Details"></ActionBar>
22

33
<FlexboxLayout flexDirection="column">
4-
<FlexboxLayout class="m-15">
5-
<Label class="h2" [text]="item.id + '. '"></Label>
6-
<Label class="h2" [text]="item.name"></Label>
4+
<FlexboxLayout class="m-4">
5+
<Label class="text-3xl text-gray-400" [text]="item()?.id + '. '"></Label>
6+
<Label class="text-3xl" [text]="item()?.name"></Label>
77
</FlexboxLayout>
8-
<Label class="h4 m-15" [text]="item.role"></Label>
8+
<Label class="text-xl m-4" [text]="item()?.role"></Label>
99
</FlexboxLayout>
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
import { Component, OnInit } from '@angular/core'
1+
import { Component, NO_ERRORS_SCHEMA, OnInit, inject, signal } from '@angular/core'
22
import { ActivatedRoute } from '@angular/router'
3-
3+
import { NativeScriptCommonModule } from '@nativescript/angular'
44
import { Item } from './item'
55
import { ItemService } from './item.service'
66

77
@Component({
8-
selector: 'ns-details',
9-
templateUrl: './item-detail.component.html',
8+
selector: 'ns-detail',
9+
templateUrl: './detail.component.html',
10+
imports: [NativeScriptCommonModule],
11+
schemas: [NO_ERRORS_SCHEMA],
1012
})
1113
export class ItemDetailComponent implements OnInit {
12-
item: Item
13-
14-
constructor(private itemService: ItemService, private route: ActivatedRoute) {}
14+
itemService = inject(ItemService)
15+
route = inject(ActivatedRoute)
16+
item = signal<Item>(null)
1517

1618
ngOnInit(): void {
1719
const id = +this.route.snapshot.params.id
18-
this.item = this.itemService.getItem(id)
20+
this.item.set(this.itemService.getItem(id))
21+
22+
// log the item to the console
23+
console.log(this.item())
1924
}
2025
}

packages/template-hello-world-ng/src/app/item/item.service.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { Injectable } from '@angular/core'
2-
1+
import { Injectable, signal } from '@angular/core'
32
import { Item } from './item'
43

54
@Injectable({
65
providedIn: 'root',
76
})
87
export class ItemService {
9-
private items = new Array<Item>(
10-
{ id: 1, name: 'Ter Stegen', role: 'Goalkeeper' },
8+
items = signal<Item[]>([
9+
{ id: 1, name: 'NativeScript', role: 'Technology' },
10+
{ id: 2, name: 'Ter Stegen', role: 'Goalkeeper' },
1111
{ id: 3, name: 'Piqué', role: 'Defender' },
1212
{ id: 4, name: 'I. Rakitic', role: 'Midfielder' },
1313
{ id: 5, name: 'Sergio', role: 'Midfielder' },
@@ -28,14 +28,10 @@ export class ItemService {
2828
{ id: 22, name: 'Aleix Vidal', role: 'Midfielder' },
2929
{ id: 23, name: 'Umtiti', role: 'Defender' },
3030
{ id: 24, name: 'Mathieu', role: 'Defender' },
31-
{ id: 25, name: 'Masip', role: 'Goalkeeper' }
32-
)
33-
34-
getItems(): Array<Item> {
35-
return this.items
36-
}
31+
{ id: 25, name: 'Masip', role: 'Goalkeeper' },
32+
])
3733

3834
getItem(id: number): Item {
39-
return this.items.filter((item) => item.id === id)[0]
35+
return this.items().find((item) => item.id === id)
4036
}
4137
}

0 commit comments

Comments
 (0)