-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Angular 19 standalone with optional zoneless (#16)
- Loading branch information
1 parent
5d96cc1
commit 230179b
Showing
18 changed files
with
558 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/// <reference path="./node_modules/@nativescript/types-minimal/index.d.ts" /> | ||
/// <reference path="./node_modules/@nativescript/types/index.d.ts" /> |
18 changes: 0 additions & 18 deletions
18
apps/nativescript-starter-angular/src/app/app-routing.module.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import { Component } from '@angular/core' | ||
import { Component, NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { PageRouterOutlet } from '@nativescript/angular'; | ||
|
||
@Component({ | ||
selector: 'ns-app', | ||
templateUrl: './app.component.html', | ||
imports: [PageRouterOutlet], | ||
schemas: [NO_ERRORS_SCHEMA], | ||
}) | ||
export class AppComponent {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Routes } from '@angular/router'; | ||
import { ItemsComponent } from './item/items.component'; | ||
import { ItemDetailComponent } from './item/item-detail.component'; | ||
|
||
export const routes: Routes = [ | ||
{ path: '', redirectTo: '/items', pathMatch: 'full' }, | ||
{ path: 'items', component: ItemsComponent }, | ||
{ path: 'item/:id', component: ItemDetailComponent }, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 14 additions & 15 deletions
29
apps/nativescript-starter-angular/src/app/item/item-detail.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
import { Item } from './item'; | ||
import { ItemService } from './item.service'; | ||
import { Component, NO_ERRORS_SCHEMA, OnInit, inject, signal } from '@angular/core' | ||
import { ActivatedRoute } from '@angular/router' | ||
import { NativeScriptCommonModule } from '@nativescript/angular' | ||
import { Item } from './item' | ||
import { ItemService } from './item.service' | ||
|
||
@Component({ | ||
selector: 'ns-details', | ||
selector: 'ns-item-detail', | ||
templateUrl: './item-detail.component.html', | ||
imports: [NativeScriptCommonModule], | ||
schemas: [NO_ERRORS_SCHEMA], | ||
}) | ||
export class ItemDetailComponent implements OnInit { | ||
item: Item; | ||
|
||
constructor( | ||
private itemService: ItemService, | ||
private route: ActivatedRoute | ||
) {} | ||
itemService = inject(ItemService) | ||
route = inject(ActivatedRoute) | ||
item = signal<Item>(null) | ||
|
||
ngOnInit(): void { | ||
const id = +this.route.snapshot.params.id; | ||
this.item = this.itemService.getItem(id); | ||
const id = +this.route.snapshot.params.id | ||
this.item.set(this.itemService.getItem(id)) | ||
|
||
// log the item to the console | ||
console.log(this.item); | ||
console.log(this.item()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/nativescript-starter-angular/src/app/item/items.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 10 additions & 15 deletions
25
apps/nativescript-starter-angular/src/app/item/items.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,25 @@ | ||
import { Component, OnInit, inject } from '@angular/core' | ||
import { Component, NO_ERRORS_SCHEMA, inject } from '@angular/core' | ||
import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular' | ||
import { Page } from '@nativescript/core' | ||
|
||
import { Item } from './item' | ||
import { ItemService } from './item.service' | ||
|
||
@Component({ | ||
selector: 'ns-items', | ||
templateUrl: './items.component.html', | ||
imports: [NativeScriptCommonModule, NativeScriptRouterModule], | ||
schemas: [NO_ERRORS_SCHEMA], | ||
}) | ||
export class ItemsComponent implements OnInit { | ||
page = inject(Page); | ||
itemService = inject(ItemService); | ||
items: Array<Item>; | ||
export class ItemsComponent { | ||
itemService = inject(ItemService) | ||
page = inject(Page) | ||
|
||
constructor() { | ||
// Setup large titles on iOS | ||
this.page.on('loaded', (args) => { | ||
if (__IOS__) { | ||
const navigationController: UINavigationController = | ||
this.page.frame.ios.controller; | ||
navigationController.navigationBar.prefersLargeTitles = true; | ||
const navigationController: UINavigationController = this.page.frame.ios.controller | ||
navigationController.navigationBar.prefersLargeTitles = true | ||
} | ||
}); | ||
} | ||
|
||
ngOnInit(): void { | ||
this.items = this.itemService.getItems() | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,31 @@ | ||
import { platformNativeScript, runNativeScriptAngularApp } from '@nativescript/angular'; | ||
import { | ||
bootstrapApplication, | ||
provideNativeScriptHttpClient, | ||
provideNativeScriptNgZone, | ||
provideNativeScriptRouter, | ||
runNativeScriptAngularApp, | ||
} from '@nativescript/angular'; | ||
import { provideExperimentalZonelessChangeDetection } from '@angular/core'; | ||
import { withInterceptorsFromDi } from '@angular/common/http'; | ||
import { routes } from './app/app.routes'; | ||
import { AppComponent } from './app/app.component'; | ||
|
||
import { AppModule } from './app/app.module'; | ||
/** | ||
* Disable zone by setting this to true | ||
* Then also adjust polyfills.ts (see note there) | ||
*/ | ||
const EXPERIMENTAL_ZONELESS = false; | ||
|
||
runNativeScriptAngularApp({ | ||
appModuleBootstrap: () => platformNativeScript().bootstrapModule(AppModule), | ||
appModuleBootstrap: () => { | ||
return bootstrapApplication(AppComponent, { | ||
providers: [ | ||
provideNativeScriptHttpClient(withInterceptorsFromDi()), | ||
provideNativeScriptRouter(routes), | ||
EXPERIMENTAL_ZONELESS | ||
? provideExperimentalZonelessChangeDetection() | ||
: provideNativeScriptNgZone(), | ||
], | ||
}); | ||
}, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { getJestProjects } from '@nx/jest'; | ||
import { getJestProjectsAsync } from '@nx/jest'; | ||
|
||
export default { | ||
projects: getJestProjects(), | ||
}; | ||
export default async () => ({ | ||
projects: await getJestProjectsAsync(), | ||
}); |
Oops, something went wrong.