mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-13 14:23:02 -05:00
feat(challengestandalone): challenge standalone
This commit is contained in:
1
libs/module-to-standalone/home/src/index.ts
Normal file
1
libs/module-to-standalone/home/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './lib/home.module';
|
||||
27
libs/module-to-standalone/home/src/lib/home.component.ts
Normal file
27
libs/module-to-standalone/home/src/lib/home.component.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { TOKEN } from '@angular-challenges/module-to-standalone/core/providers';
|
||||
import { AuthorizationService } from '@angular-challenges/module-to-standalone/core/service';
|
||||
import { Component, Inject } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'lib-home',
|
||||
template: `Home component
|
||||
|
||||
<section class="flex gap-5 items-center">
|
||||
Authorization :
|
||||
<button class="border p-2 " (click)="authorizeService.authorize()">
|
||||
Authorize
|
||||
</button>
|
||||
<button class="border p-2 " (click)="authorizeService.forbid()">
|
||||
Forbid
|
||||
</button>
|
||||
(isAuthorized: {{ authorizeService.isAuthorized$ | async }})
|
||||
</section>
|
||||
|
||||
<section>LoadedToken {{ token }}</section> `,
|
||||
})
|
||||
export class HomeComponent {
|
||||
constructor(
|
||||
public authorizeService: AuthorizationService,
|
||||
@Inject(TOKEN) public token: string
|
||||
) {}
|
||||
}
|
||||
13
libs/module-to-standalone/home/src/lib/home.module.ts
Normal file
13
libs/module-to-standalone/home/src/lib/home.module.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { HomeComponent } from './home.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [HomeComponent],
|
||||
imports: [
|
||||
RouterModule.forChild([{ path: '', component: HomeComponent }]),
|
||||
CommonModule,
|
||||
],
|
||||
})
|
||||
export class ModuleToStandaloneHomeModule {}
|
||||
8
libs/module-to-standalone/home/src/test-setup.ts
Normal file
8
libs/module-to-standalone/home/src/test-setup.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
|
||||
globalThis.ngJest = {
|
||||
testEnvironmentOptions: {
|
||||
errorOnUnknownElements: true,
|
||||
errorOnUnknownProperties: true,
|
||||
},
|
||||
};
|
||||
import 'jest-preset-angular/setup-jest';
|
||||
Reference in New Issue
Block a user