Skip to content

Commit 230179b

Browse files
authored
feat: Angular 19 standalone with optional zoneless (#16)
1 parent 5d96cc1 commit 230179b

18 files changed

+558
-516
lines changed

apps/nativescript-starter-angular/package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44
"version": "1.0.0",
55
"private": true,
66
"dependencies": {
7-
"@angular/animations": "~18.0.0",
8-
"@angular/common": "~18.0.0",
9-
"@angular/compiler": "~18.0.0",
10-
"@angular/core": "~18.0.0",
11-
"@angular/forms": "~18.0.0",
12-
"@angular/platform-browser": "~18.0.0",
13-
"@angular/platform-browser-dynamic": "~18.0.0",
14-
"@angular/router": "~18.0.0",
15-
"@nativescript/angular": "^18.0.0",
7+
"@angular/animations": "~19.0.0",
8+
"@angular/common": "~19.0.0",
9+
"@angular/compiler": "~19.0.0",
10+
"@angular/core": "~19.0.0",
11+
"@angular/forms": "~19.0.0",
12+
"@angular/platform-browser": "~19.0.0",
13+
"@angular/platform-browser-dynamic": "~19.0.0",
14+
"@angular/router": "~19.0.0",
15+
"@nativescript/angular": "^19.0.0",
1616
"@nativescript/core": "~8.8.0",
1717
"rxjs": "~7.8.0",
18-
"zone.js": "~0.14.2"
18+
"zone.js": "~0.15.0"
1919
},
2020
"devDependencies": {
21-
"@angular-devkit/build-angular": "~18.0.0",
22-
"@angular/compiler-cli": "~18.0.0",
21+
"@angular-devkit/build-angular": "~19.0.0",
22+
"@angular/compiler-cli": "~19.0.0",
2323
"@nativescript/preview-cli": "1.0.13",
2424
"@nativescript/stackblitz": "0.0.8",
2525
"@nativescript/tailwind": "^2.1.0",
26-
"@nativescript/types-minimal": "~8.8.0",
26+
"@nativescript/types": "~8.8.0",
2727
"@nativescript/webpack": "~5.0.0",
28-
"@ngtools/webpack": "~18.0.0",
28+
"@ngtools/webpack": "~19.0.0",
2929
"tailwindcss": "~3.4.0",
30-
"typescript": "~5.4.0"
30+
"typescript": "~5.6.0"
3131
}
3232
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/// <reference path="./node_modules/@nativescript/types-minimal/index.d.ts" />
1+
/// <reference path="./node_modules/@nativescript/types/index.d.ts" />

apps/nativescript-starter-angular/src/app/app-routing.module.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 4 additions & 1 deletion
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 {}

apps/nativescript-starter-angular/src/app/app.module.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
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+
];

apps/nativescript-starter-angular/src/app/item/item-detail.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<FlexboxLayout flexDirection="column">
44
<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>
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="text-xl m-4" [text]="item.role"></Label>
8+
<Label class="text-xl m-4" [text]="item()?.role"></Label>
99
</FlexboxLayout>
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
import { Component, OnInit } from '@angular/core';
2-
import { ActivatedRoute } from '@angular/router';
3-
4-
import { Item } from './item';
5-
import { ItemService } from './item.service';
1+
import { Component, NO_ERRORS_SCHEMA, OnInit, inject, signal } from '@angular/core'
2+
import { ActivatedRoute } from '@angular/router'
3+
import { NativeScriptCommonModule } from '@nativescript/angular'
4+
import { Item } from './item'
5+
import { ItemService } from './item.service'
66

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

1918
ngOnInit(): void {
20-
const id = +this.route.snapshot.params.id;
21-
this.item = this.itemService.getItem(id);
19+
const id = +this.route.snapshot.params.id
20+
this.item.set(this.itemService.getItem(id))
2221

2322
// log the item to the console
24-
console.log(this.item);
23+
console.log(this.item())
2524
}
2625
}

apps/nativescript-starter-angular/src/app/item/item.service.ts

Lines changed: 7 additions & 11 deletions
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
}

apps/nativescript-starter-angular/src/app/item/items.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<ActionBar title="My App"> </ActionBar>
22

33
<GridLayout>
4-
<ListView [items]="items">
4+
<ListView [items]="itemService.items()">
55
<ng-template let-item="item">
66
<StackLayout [nsRouterLink]="['/item', item.id]">
77
<Label [text]="item.name" class="text-lg text-gray-500 p-4"></Label>

0 commit comments

Comments
 (0)