Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { RouterLink, RouterOutlet } from '@angular/router';

@Component({
selector: 'app-root',
Expand Down Expand Up @@ -26,6 +27,6 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
class: 'flex flex-col p-4 gap-3',
},
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false,
imports: [RouterLink, RouterOutlet],
})
export class AppComponent {}
11 changes: 0 additions & 11 deletions apps/angular/31-module-to-standalone/src/app/app.module.ts

This file was deleted.

17 changes: 9 additions & 8 deletions apps/angular/31-module-to-standalone/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { provideZoneChangeDetection } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { importProvidersFrom } from '@angular/core';

platformBrowserDynamic()
.bootstrapModule(AppModule, {
applicationProviders: [provideZoneChangeDetection()],
})
.catch((err) => console.error(err));
import appRoutes from '@angular-challenges/module-to-standalone/shell';
import { BrowserModule, bootstrapApplication } from '@angular/platform-browser';
import { provideRouter } from '@angular/router';
import { AppComponent } from './app/app.component';

bootstrapApplication(AppComponent, {
providers: [importProvidersFrom(BrowserModule), provideRouter(appRoutes)],
}).catch((err) => console.error(err));
4 changes: 3 additions & 1 deletion libs/module-to-standalone/admin/feature/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './lib/admin-feature.module';
import { adminFeatureRoutes } from './lib/admin-feature.routes';

export default adminFeatureRoutes;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Routes } from '@angular/router';

export const adminFeatureRoutes: Routes = [
{
path: '',
loadComponent: () => import('./dashboard/dashboard.component'),
},
{
path: 'create-user',
loadComponent: () => import('./create-user/create-user.component'),
},
];
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { RouterLink } from '@angular/router';

@Component({
selector: 'lib-create-user',
Expand All @@ -12,15 +12,7 @@ import { RouterModule } from '@angular/router';
Back
</button>
`,
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [RouterLink],
})
export class CreateUserComponent {}

@NgModule({
imports: [
RouterModule.forChild([{ path: '', component: CreateUserComponent }]),
],
declarations: [CreateUserComponent],
})
export class CreateUserModule {}
export default class CreateUserComponent {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { RouterLink } from '@angular/router';

@Component({
selector: 'lib-dashboard',
Expand All @@ -12,15 +12,7 @@ import { RouterModule } from '@angular/router';
Create User
</button>
`,
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [RouterLink],
})
export class DashboardComponent {}

@NgModule({
imports: [
RouterModule.forChild([{ path: '', component: DashboardComponent }]),
],
declarations: [DashboardComponent],
})
export class DashboardModule {}
export default class DashboardComponent {}
4 changes: 3 additions & 1 deletion libs/module-to-standalone/forbidden/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './lib/forbidden.module';
import { ForbiddenComponent } from './lib/forbidden.component';

export default ForbiddenComponent;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
template: `
Forbidden component
`,
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ForbiddenComponent {}
13 changes: 0 additions & 13 deletions libs/module-to-standalone/forbidden/src/lib/forbidden.module.ts

This file was deleted.

4 changes: 3 additions & 1 deletion libs/module-to-standalone/home/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './lib/home.module';
import { HomeComponent } from './lib/home.component';

export default HomeComponent;
5 changes: 3 additions & 2 deletions libs/module-to-standalone/home/src/lib/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TOKEN } from '@angular-challenges/module-to-standalone/core/providers';
import { AuthorizationService } from '@angular-challenges/module-to-standalone/core/service';
import { AsyncPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';

@Component({
Expand All @@ -20,8 +21,8 @@ import { ChangeDetectionStrategy, Component, inject } from '@angular/core';

<section>LoadedToken {{ token }}</section>
`,
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [AsyncPipe],
})
export class HomeComponent {
public authorizeService = inject(AuthorizationService);
Expand Down
13 changes: 0 additions & 13 deletions libs/module-to-standalone/home/src/lib/home.module.ts

This file was deleted.

4 changes: 3 additions & 1 deletion libs/module-to-standalone/shell/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './lib/main-shell.module';
import { appRoutes } from './lib/main-shell.routes';

export default appRoutes;
11 changes: 0 additions & 11 deletions libs/module-to-standalone/shell/src/lib/main-shell.module.ts

This file was deleted.

55 changes: 27 additions & 28 deletions libs/module-to-standalone/shell/src/lib/main-shell.routes.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
import { IsAuthorizedGuard } from '@angular-challenges/module-to-standalone/admin/shared';
import { provideToken } from '@angular-challenges/module-to-standalone/core/providers';
import { Route } from '@angular/router';

export const appRoutes: Route[] = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{
path: 'home',
loadChildren: () =>
import('@angular-challenges/module-to-standalone/home').then(
(m) => m.ModuleToStandaloneHomeModule,
),
},
{
path: 'admin',
canActivate: [IsAuthorizedGuard],
loadChildren: () =>
import('@angular-challenges/module-to-standalone/admin/feature').then(
(m) => m.AdminFeatureModule,
),
},
{
path: 'user',
loadChildren: () =>
import('@angular-challenges/module-to-standalone/user/shell').then(
(m) => m.UserShellModule,
),
},
path: '',
providers: [provideToken('main-shell-token')],
children: [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{
path: 'home',
loadComponent: () =>
import('@angular-challenges/module-to-standalone/home'),
},
{
path: 'admin',
canActivate: [IsAuthorizedGuard],
loadChildren: () =>
import('@angular-challenges/module-to-standalone/admin/feature'),
},
{
path: 'user',
loadChildren: () =>
import('@angular-challenges/module-to-standalone/user/shell'),
},

{
path: 'forbidden',
loadChildren: () =>
import('@angular-challenges/module-to-standalone/forbidden').then(
(m) => m.ForbiddenModule,
),
{
path: 'forbidden',
loadComponent: () =>
import('@angular-challenges/module-to-standalone/forbidden'),
},
],
},
];
4 changes: 3 additions & 1 deletion libs/module-to-standalone/user/contact/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './lib/contact-feature.module';
import { contactFeatureRoutes } from './lib/contact-feature.routes';

export default contactFeatureRoutes;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Route } from '@angular/router';

export const contactFeatureRoutes: Route[] = [
{
path: '',
loadComponent: () => import('./dashboard/dashboard.component'),
},
{
path: 'create-contact',
loadComponent: () => import('./create-contact/create-contact.component'),
},
];
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { RouterLink } from '@angular/router';

@Component({
selector: 'lib-create-contact',
Expand All @@ -12,15 +12,7 @@ import { RouterModule } from '@angular/router';
Back
</button>
`,
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [RouterLink],
})
export class CreateContactComponent {}

@NgModule({
imports: [
RouterModule.forChild([{ path: '', component: CreateContactComponent }]),
],
declarations: [CreateContactComponent],
})
export class CreateContactModule {}
export default class CreateContactComponent {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { RouterLink } from '@angular/router';

@Component({
selector: 'lib-contact-dashboard',
Expand All @@ -12,15 +12,7 @@ import { RouterModule } from '@angular/router';
Create contact
</button>
`,
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [RouterLink],
})
export class ContactDashboardComponent {}

@NgModule({
imports: [
RouterModule.forChild([{ path: '', component: ContactDashboardComponent }]),
],
declarations: [ContactDashboardComponent],
})
export class ContactDashboardModule {}
export default class ContactDashboardComponent {}
4 changes: 3 additions & 1 deletion libs/module-to-standalone/user/home/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './lib/home.module';
import { UserHomeComponent } from './lib/home.component';

export default UserHomeComponent;
Loading
Loading