Skip to content

Commit 50153e1

Browse files
committed
fix: standalone migration
1 parent 1f8a422 commit 50153e1

16 files changed

+61
-125
lines changed

projects/sandbox/src/app/app-routing.module.ts

-27
This file was deleted.

projects/sandbox/src/app/app.component.spec.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import { AppComponent } from './app.component';
55
describe('AppComponent', () => {
66
beforeEach(async () => {
77
await TestBed.configureTestingModule({
8-
imports: [
9-
RouterTestingModule
10-
],
11-
declarations: [
8+
imports: [
9+
RouterTestingModule,
1210
AppComponent
13-
],
14-
}).compileComponents();
11+
]
12+
}).compileComponents();
1513
});
1614

1715
it('should create the app', () => {

projects/sandbox/src/app/app.component.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { Component } from '@angular/core';
2+
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
23

34
@Component({
4-
selector: 'app-root',
5-
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.scss']
5+
selector: 'app-root',
6+
templateUrl: './app.component.html',
7+
styleUrls: ['./app.component.scss'],
8+
standalone: true,
9+
imports: [RouterLink, RouterLinkActive, RouterOutlet]
710
})
811
export class AppComponent {
912

projects/sandbox/src/app/app.module.ts

-18
This file was deleted.
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Routes } from '@angular/router';
2+
3+
export const appRoutes: Routes = [
4+
{
5+
path: 'users',
6+
title: 'Users',
7+
loadChildren: () => import('./users/users.routes').then((m) => m.routes),
8+
},
9+
{
10+
path: 'home',
11+
title: 'Home',
12+
loadChildren: () => import('./home/home.routes').then((m) => m.routes),
13+
},
14+
{
15+
path: '',
16+
pathMatch: 'full',
17+
redirectTo: 'home',
18+
},
19+
];

projects/sandbox/src/app/home/home-routing.module.ts

-11
This file was deleted.

projects/sandbox/src/app/home/home.component.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ describe('HomeComponent', () => {
88

99
beforeEach(async () => {
1010
await TestBed.configureTestingModule({
11-
declarations: [ HomeComponent ]
12-
})
11+
imports: [HomeComponent]
12+
})
1313
.compileComponents();
1414
});
1515

projects/sandbox/src/app/home/home.component.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Component, OnInit } from '@angular/core';
22

33
@Component({
4-
selector: 'app-home',
5-
templateUrl: './home.component.html',
6-
styleUrls: ['./home.component.scss']
4+
selector: 'app-home',
5+
templateUrl: './home.component.html',
6+
styleUrls: ['./home.component.scss'],
7+
standalone: true
78
})
89
export class HomeComponent implements OnInit {
910

projects/sandbox/src/app/home/home.module.ts

-17
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Routes } from '@angular/router';
2+
import { HomeComponent } from './home.component';
3+
4+
export const routes: Routes = [{ path: '', component: HomeComponent }];

projects/sandbox/src/app/users/users-routing.module.ts

-11
This file was deleted.

projects/sandbox/src/app/users/users.component.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ describe('UsersComponent', () => {
88

99
beforeEach(async () => {
1010
await TestBed.configureTestingModule({
11-
declarations: [ UsersComponent ]
12-
})
11+
imports: [UsersComponent]
12+
})
1313
.compileComponents();
1414
});
1515

projects/sandbox/src/app/users/users.component.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { Component, OnInit, TrackByFunction } from '@angular/core';
2+
import { NgFor } from '@angular/common';
23

34
interface User {
45
id: number;
56
name: string;
67
}
78

89
@Component({
9-
selector: 'app-users',
10-
templateUrl: './users.component.html',
11-
styleUrls: ['./users.component.scss']
10+
selector: 'app-users',
11+
templateUrl: './users.component.html',
12+
styleUrls: ['./users.component.scss'],
13+
standalone: true,
14+
imports: [NgFor]
1215
})
1316
export class UsersComponent implements OnInit {
1417

projects/sandbox/src/app/users/users.module.ts

-17
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Routes } from '@angular/router';
2+
import { UsersComponent } from './users.component';
3+
4+
export const routes: Routes = [{ path: '', component: UsersComponent }];

projects/sandbox/src/main.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
import { enableProdMode } from '@angular/core';
2-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
1+
import { enableProdMode, importProvidersFrom } from '@angular/core';
32

4-
import { AppModule } from './app/app.module';
3+
import { bootstrapApplication, BrowserModule } from '@angular/platform-browser';
4+
import { RouterModule } from '@angular/router';
5+
import { AppComponent } from './app/app.component';
6+
import { appRoutes } from './app/app.routes';
57
import { environment } from './environments/environment';
68

79
if (environment.production) {
810
enableProdMode();
911
}
1012

11-
platformBrowserDynamic().bootstrapModule(AppModule)
12-
.catch(err => console.error(err));
13+
bootstrapApplication(AppComponent, {
14+
providers: [
15+
importProvidersFrom(BrowserModule, RouterModule.forRoot(appRoutes)),
16+
],
17+
}).catch((err) => console.error(err));

0 commit comments

Comments
 (0)