Skip to content

Commit 90c037c

Browse files
committed
feat: add angular 19 support
1 parent 7f176ef commit 90c037c

25 files changed

+2953
-3734
lines changed

apps/nativescript-demo-ng/src/app/app.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Component, ViewContainerRef, OnInit, OnDestroy } from '@angular/core';
55
selector: 'ns-app',
66
moduleId: module.id,
77
templateUrl: './app.component.html',
8+
standalone: false,
89
})
910
export class AppComponent implements OnInit, OnDestroy {
1011
constructor(private vcRef: ViewContainerRef) {}

apps/nativescript-demo-ng/src/app/home/home.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Page, TabView } from '@nativescript/core';
77
moduleId: module.id,
88
selector: 'demo-home',
99
templateUrl: './home.component.html',
10+
standalone: false,
1011
})
1112
export class HomeComponent implements OnInit {
1213
tabItems: { [key: string]: { index: number; title?: string; iconSource?: string; textTransform?: string } } = {};

apps/nativescript-demo-ng/src/app/item/item-detail.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import { ItemService } from './item.service';
77
@Component({
88
selector: 'ns-details',
99
moduleId: module.id,
10-
templateUrl: './item-detail.component.html'
10+
templateUrl: './item-detail.component.html',
11+
standalone: false,
1112
})
1213
export class ItemDetailComponent implements OnInit {
1314
item: Item;
1415

1516
constructor(
1617
private itemService: ItemService,
17-
private route: ActivatedRoute
18+
private route: ActivatedRoute,
1819
) {}
1920

2021
ngOnInit(): void {

apps/nativescript-demo-ng/src/app/item/items.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ModalDialogService, NativeDialogService } from '@nativescript/angular';
1010
selector: 'ns-items',
1111
moduleId: module.id,
1212
templateUrl: './items.component.html',
13+
standalone: false,
1314
})
1415
export class ItemsComponent implements OnInit, OnDestroy {
1516
message = 'Hello Angular 18!';

apps/nativescript-demo-ng/src/app/item2/item-detail2.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ItemService } from '../item/item.service';
99
selector: 'ns-details2',
1010
moduleId: module.id,
1111
templateUrl: './item-detail2.component.html',
12+
standalone: false,
1213
})
1314
export class ItemDetailComponent implements OnInit, OnDestroy {
1415
item: Item;

apps/nativescript-demo-ng/src/app/item3/items.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import { ModalDialogService, NativeDialogService } from '@nativescript/angular';
1010
selector: 'ns-items',
1111
moduleId: module.id,
1212
templateUrl: './items.component.html',
13+
standalone: false,
1314
})
1415
export class ItemsComponent implements OnInit, OnDestroy {
15-
message = 'Hello Angular 18';
16+
message = 'Hello Angular 19';
1617
items: Array<Item>;
1718
borderRadius: number;
1819
fontSize: number;

apps/nativescript-demo-ng/src/app/modal/modal.component.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { View } from '@nativescript/core';
66
@Component({
77
selector: 'ns-modal',
88
templateUrl: `./modal.component.html`,
9+
standalone: false,
910
})
1011
export class ModalComponent implements OnInit, OnDestroy {
1112
id = Math.floor(Math.random() * 1000);
@@ -46,15 +47,16 @@ export class ModalComponent implements OnInit, OnDestroy {
4647
loadedImg(args) {
4748
this.img = args.object as View;
4849
const scaleImage = (up: boolean) => {
49-
this.img.animate({
50-
scale: { x: up ? 1.5 : 1.0, y: up ? 1.5 : 1.0},
51-
translate: { x: up ? -100 : 0, y: 0},
52-
duration: 1000,
53-
54-
}).then(() => {
55-
scaleImage(up ? false : true);
56-
})
57-
}
50+
this.img
51+
.animate({
52+
scale: { x: up ? 1.5 : 1.0, y: up ? 1.5 : 1.0 },
53+
translate: { x: up ? -100 : 0, y: 0 },
54+
duration: 1000,
55+
})
56+
.then(() => {
57+
scaleImage(up ? false : true);
58+
});
59+
};
5860
scaleImage(true);
5961
}
6062
}

apps/nativescript-demo-ng/src/tests/detached-loader-tests.spec.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// make sure you import mocha-config before @angular/core
2-
import { NgModule, Directive, ChangeDetectionStrategy, Component, ViewChild, NO_ERRORS_SCHEMA } from '@angular/core';
3-
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { ChangeDetectionStrategy, Component, Directive, NgModule, NO_ERRORS_SCHEMA, ViewChild } from '@angular/core';
3+
import { TestBed } from '@angular/core/testing';
44
import { DetachedLoader, NativeScriptModule } from '@nativescript/angular';
55
import { NativeScriptTestingModule } from '@nativescript/angular/testing';
66
// import { NS_COMPILER_PROVIDERS } from "@nativescript/angular/platform";
77
import { CommonModule } from '@angular/common';
88

99
@Component({
1010
template: `<StackLayout><Label text="COMPONENT"></Label></StackLayout>`,
11+
schemas: [NO_ERRORS_SCHEMA],
1112
})
1213
export class TestComponent {}
1314

@@ -23,6 +24,8 @@ class LoaderComponentBase {
2324
<DetachedContainer #loader></DetachedContainer>
2425
</StackLayout>
2526
`,
27+
imports: [DetachedLoader],
28+
schemas: [NO_ERRORS_SCHEMA],
2629
})
2730
export class LoaderComponent extends LoaderComponentBase {}
2831

@@ -34,22 +37,22 @@ export class LoaderComponent extends LoaderComponentBase {}
3437
<DetachedContainer #loader></DetachedContainer>
3538
</StackLayout>
3639
`,
40+
imports: [DetachedLoader],
41+
schemas: [NO_ERRORS_SCHEMA],
3742
})
3843
// eslint-disable-next-line @angular-eslint/component-class-suffix
3944
export class LoaderComponentOnPush extends LoaderComponentBase {}
4045

4146
@NgModule({
42-
declarations: [LoaderComponent, LoaderComponentOnPush, TestComponent],
43-
imports: [NativeScriptModule, NativeScriptTestingModule, CommonModule],
47+
imports: [LoaderComponent, LoaderComponentOnPush, TestComponent],
4448
schemas: [NO_ERRORS_SCHEMA],
4549
})
4650
export class EntryComponentsTestModule {}
4751
describe('DetachedLoader', function () {
4852
// this.timeout(4000);
4953
beforeEach(() => {
5054
TestBed.configureTestingModule({
51-
declarations: [LoaderComponent, LoaderComponentOnPush, TestComponent],
52-
imports: [NativeScriptModule, NativeScriptTestingModule, CommonModule],
55+
imports: [NativeScriptModule, NativeScriptTestingModule, CommonModule, LoaderComponent, LoaderComponentOnPush, TestComponent],
5356
schemas: [NO_ERRORS_SCHEMA],
5457
});
5558
return TestBed.compileComponents();

apps/nativescript-demo-ng/src/tests/detached-utils-tests.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { GridLayout, ProxyViewContainer } from '@nativescript/core';
55

66
@Component({
77
template: `<ng-container #vc></ng-container><ng-template #template><GridLayout></GridLayout></ng-template>`,
8+
schemas: [NO_ERRORS_SCHEMA],
89
})
910
export class GenerateViewComponent {
1011
@ViewChild('vc', { read: ViewContainerRef }) vc: ViewContainerRef;
@@ -14,11 +15,12 @@ export class GenerateViewComponent {
1415

1516
@Component({
1617
template: `<GridLayout></GridLayout>`,
18+
schemas: [NO_ERRORS_SCHEMA],
1719
})
1820
export class GeneratedComponent {}
1921

2022
@NgModule({
21-
declarations: [GeneratedComponent, GenerateViewComponent],
23+
imports: [GeneratedComponent, GenerateViewComponent],
2224
schemas: [NO_ERRORS_SCHEMA],
2325
})
2426
export class GeneratedModule {}
@@ -28,7 +30,7 @@ describe('generateNativeScriptView', () => {
2830
let cleanup: Array<NgViewRef<unknown> | ComponentRef<unknown> | EmbeddedViewRef<unknown>> = [];
2931
beforeEach(async () => {
3032
await TestBed.configureTestingModule({
31-
declarations: [GenerateViewComponent, GeneratedComponent],
33+
imports: [GenerateViewComponent, GeneratedComponent],
3234
}).compileComponents();
3335
fixture = TestBed.createComponent(GenerateViewComponent);
3436
fixture.detectChanges();

apps/nativescript-demo-ng/src/tests/list-view-tests.spec.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import { Component, Input, NgModule, NO_ERRORS_SCHEMA, ViewChild } from '@angular/core';
1+
import { Component, Input, NO_ERRORS_SCHEMA, ViewChild } from '@angular/core';
22
import { TestBed, waitForAsync } from '@angular/core/testing';
3-
import { ListViewComponent, NativeScriptModule } from '@nativescript/angular';
3+
import { ListViewComponent, TemplateKeyDirective } from '@nativescript/angular';
44
// import trace = require("trace");
55
// trace.setCategories("ns-list-view, " + trace.categories.Navigation);
66
// trace.enable();
77

88
class DataItem {
9-
constructor(public id: number, public name: string) {}
9+
constructor(
10+
public id: number,
11+
public name: string,
12+
) {}
1013
}
1114

1215
const ITEMS = [new DataItem(0, 'data item 0'), new DataItem(1, 'data item 1'), new DataItem(2, 'data item 2')];
@@ -24,6 +27,8 @@ let testTemplates: { first: number; second: number };
2427
</ListView>
2528
</GridLayout>
2629
`,
30+
imports: [ListViewComponent],
31+
schemas: [NO_ERRORS_SCHEMA],
2732
})
2833
export class TestListViewComponent {
2934
public myItems: Array<DataItem> = ITEMS;
@@ -63,6 +68,8 @@ export class ItemTemplateComponent {
6368
</ListView>
6469
</GridLayout>
6570
`,
71+
imports: [ListViewComponent, TemplateKeyDirective, ItemTemplateComponent],
72+
schemas: [NO_ERRORS_SCHEMA],
6673
})
6774
export class TestListViewSelectorComponent {
6875
public myItems: Array<DataItem> = ITEMS;
@@ -94,6 +101,8 @@ export class TestListViewSelectorComponent {
94101
</ListView>
95102
</GridLayout>
96103
`,
104+
imports: [ListViewComponent, TemplateKeyDirective, ItemTemplateComponent],
105+
schemas: [NO_ERRORS_SCHEMA],
97106
})
98107
export class TestListViewSelectorWithEventsComponent {
99108
public myItems: Array<DataItem> = ITEMS;
@@ -115,6 +124,8 @@ export class TestListViewSelectorWithEventsComponent {
115124
<ListView #listView [items]="myItems"></ListView>
116125
</GridLayout>
117126
`,
127+
imports: [ListViewComponent],
128+
schemas: [NO_ERRORS_SCHEMA],
118129
})
119130
export class TestDefaultItemTemplateComponent {
120131
public myItems: Array<DataItem>;
@@ -132,20 +143,12 @@ export class TestDefaultItemTemplateComponent {
132143

133144
const declarations = [TestListViewComponent, TestListViewSelectorComponent, ItemTemplateComponent, TestDefaultItemTemplateComponent, TestListViewSelectorWithEventsComponent];
134145

135-
@NgModule({
136-
declarations: [...declarations],
137-
imports: [NativeScriptModule],
138-
schemas: [NO_ERRORS_SCHEMA],
139-
})
140-
export class ListViewModule {}
141-
142146
describe('ListView-tests', () => {
143147
beforeEach(() =>
144148
TestBed.configureTestingModule({
145-
declarations: [...declarations],
146-
imports: [NativeScriptModule],
149+
imports: declarations,
147150
schemas: [NO_ERRORS_SCHEMA],
148-
}).compileComponents()
151+
}).compileComponents(),
149152
);
150153

151154
it('setupItemView is called for every item', waitForAsync(async () => {

apps/nativescript-demo-ng/src/tests/modal-dialog.spec.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
// make sure you import mocha-config before @angular/core
2-
import { NgModule, Component, ViewContainerRef, NO_ERRORS_SCHEMA } from '@angular/core';
3-
import { Page, Frame, isIOS } from '@nativescript/core';
4-
import { ModalDialogParams, ModalDialogService } from '@nativescript/angular';
5-
6-
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
7-
import { nsTestBedRender, nsTestBedAfterEach, nsTestBedBeforeEach, NATIVESCRIPT_TESTING_PROVIDERS, NativeScriptTestingModule } from '@nativescript/angular/testing';
8-
import { NSLocationStrategy, Outlet } from '@nativescript/angular';
9-
import { FrameService } from '@nativescript/angular';
10-
import { DetachedLoader, NativeScriptModule } from '@nativescript/angular';
11-
import { platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
12-
// import { NS_COMPILER_PROVIDERS } from "@nativescript/angular/platform";
13-
import { CommonModule } from '@angular/common';
2+
import { Component, NgModule, NO_ERRORS_SCHEMA, ViewContainerRef } from '@angular/core';
3+
import { TestBed, waitForAsync } from '@angular/core/testing';
4+
import { FrameService, ModalDialogParams, ModalDialogService, NSLocationStrategy, Outlet } from '@nativescript/angular';
5+
import { Frame, isIOS } from '@nativescript/core';
146

157
import { FakeFrameService } from './ns-location-strategy.spec';
168
const CLOSE_WAIT = isIOS ? 1000 : 0;
179

1810
@Component({
1911
selector: 'modal-comp',
2012
template: `<Label text="this is modal component" (shownModally)="onShownModally()"></Label>`,
13+
schemas: [NO_ERRORS_SCHEMA],
2114
})
2215
export class ModalComponent {
2316
constructor(public params: ModalDialogParams) {}
@@ -32,6 +25,7 @@ export class ModalComponent {
3225
selector: 'fail-comp',
3326
providers: [ModalDialogService],
3427
template: `<Label text="This app is doomed"></Label>`,
28+
schemas: [NO_ERRORS_SCHEMA],
3529
})
3630
export class FailComponent {
3731
constructor(public service: ModalDialogService) {}
@@ -43,6 +37,7 @@ export class FailComponent {
4337
template: ` <GridLayout margin="20">
4438
<Label text="Modal dialogs"></Label>
4539
</GridLayout>`,
40+
schemas: [NO_ERRORS_SCHEMA],
4641
})
4742
export class SuccessComponent {
4843
constructor(
@@ -54,7 +49,7 @@ export class SuccessComponent {
5449
}
5550

5651
@NgModule({
57-
declarations: [FailComponent, SuccessComponent, ModalComponent],
52+
imports: [FailComponent, SuccessComponent, ModalComponent],
5853
exports: [FailComponent, SuccessComponent, ModalComponent],
5954
// entryComponents: [ModalComponent],
6055
schemas: [NO_ERRORS_SCHEMA],
@@ -69,8 +64,7 @@ describe('modal-dialog', () => {
6964
// [ModalComponent]));
7065
beforeEach(() => {
7166
return TestBed.configureTestingModule({
72-
declarations: [FailComponent, SuccessComponent, ModalComponent],
73-
imports: [],
67+
imports: [FailComponent, SuccessComponent, ModalComponent],
7468
providers: [{ provide: FrameService, useValue: new FakeFrameService() }, NSLocationStrategy],
7569
}).compileComponents();
7670
});

apps/nativescript-demo-ng/src/tests/platform-filter-components.spec.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
// make sure you import mocha-config before @angular/core
22
import { Component, ElementRef, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
3-
import { dumpView, createDevice } from './test-utils.spec';
4-
import { DEVICE, NativeScriptCommonModule, NativeScriptModule, registerElement } from '@nativescript/angular';
5-
import { platformNames } from '@nativescript/core/platform';
63
import { TestBed } from '@angular/core/testing';
7-
import { StackLayout } from '@nativescript/core';
4+
import { AndroidFilterComponent, DEVICE, IOSFilterComponent, NativeScriptModule } from '@nativescript/angular';
5+
import { platformNames } from '@nativescript/core/platform';
6+
import { createDevice, dumpView } from './test-utils.spec';
87
@Component({
98
template: ` <StackLayout>
109
<ios><Label text="IOS"></Label></ios>
1110
</StackLayout>`,
11+
imports: [IOSFilterComponent],
12+
schemas: [NO_ERRORS_SCHEMA],
1213
})
1314
export class IosSpecificComponent {
1415
constructor(public elementRef: ElementRef) {}
@@ -18,6 +19,8 @@ export class IosSpecificComponent {
1819
template: ` <StackLayout>
1920
<android><Label text="ANDROID"></Label></android>
2021
</StackLayout>`,
22+
imports: [AndroidFilterComponent],
23+
schemas: [NO_ERRORS_SCHEMA],
2124
})
2225
export class AndroidSpecificComponent {
2326
constructor(public elementRef: ElementRef) {}
@@ -27,25 +30,19 @@ export class AndroidSpecificComponent {
2730
template: ` <StackLayout>
2831
<Label android:text="ANDROID" ios:text="IOS"></Label>
2932
</StackLayout>`,
33+
schemas: [NO_ERRORS_SCHEMA],
3034
})
3135
export class PlatformSpecificAttributeComponent {
3236
constructor(public elementRef: ElementRef) {}
3337
}
3438

3539
const DECLARATIONS = [PlatformSpecificAttributeComponent, AndroidSpecificComponent, IosSpecificComponent];
36-
@NgModule({
37-
declarations: DECLARATIONS,
38-
imports: [NativeScriptModule],
39-
schemas: [NO_ERRORS_SCHEMA],
40-
})
41-
export class PlatformModule {}
4240

4341
describe('Platform filter directives', () => {
4442
describe('on IOS device', () => {
4543
beforeEach(() => {
4644
return TestBed.configureTestingModule({
47-
imports: [],
48-
declarations: DECLARATIONS,
45+
imports: DECLARATIONS,
4946
providers: [{ provide: DEVICE, useValue: createDevice(platformNames.ios) }],
5047
schemas: [NO_ERRORS_SCHEMA],
5148
}).compileComponents();
@@ -77,8 +74,7 @@ describe('Platform filter directives', () => {
7774
describe('on Android device', () => {
7875
beforeEach(() => {
7976
return TestBed.configureTestingModule({
80-
imports: [],
81-
declarations: DECLARATIONS,
77+
imports: DECLARATIONS,
8278
providers: [{ provide: DEVICE, useValue: createDevice(platformNames.android) }],
8379
schemas: [NO_ERRORS_SCHEMA],
8480
}).compileComponents();

0 commit comments

Comments
 (0)