Compare commits

...

2 commits

Author SHA1 Message Date
de9c829ff5 chore(deps): update devdependencies (non-major)
Some checks failed
renovate/artifacts Artifact file update failure
2025-03-04 07:03:48 +00:00
3f4d5799f7
feat: add Test2 component with dynamic loading feature 2025-03-04 07:43:03 +01:00
9 changed files with 60 additions and 9 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -29,7 +29,7 @@
"@angular/compiler-cli": "^19.0.0",
"@types/jasmine": "~5.1.0",
"autoprefixer": "^10.4.20",
"jasmine-core": "~5.1.0",
"jasmine-core": "~5.6.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
@ -37,6 +37,6 @@
"karma-jasmine-html-reporter": "~2.1.0",
"postcss": "^8.4.41",
"tailwindcss": "^3.4.10",
"typescript": "~5.5.2"
"typescript": "~5.8.0"
}
}

View file

@ -1,14 +1,12 @@
import { Routes } from '@angular/router';
import { HotelListComponent } from './hotel-list/hotel-list.component';
import { TestComponent } from './test/test.component';
import { NewHotelComponent } from './new-hotel/new-hotel.component';
export const routes: Routes = [
{
path: '',
loadComponent: () =>
import('./hotel-list/hotel-list.component').then(
(c) => c.HotelListComponent,
),
component: HotelListComponent,
},
{
path: 'hotels/:id',

View file

@ -1,5 +1,7 @@
<div class="container p-4 mx-auto max-w-4xl">
<h1>{{ "hello" | uppercase | text }}</h1>
<button (click)="loadTest2()">Load Test2</button>
<ng-container #test2></ng-container>
<h1 class="mt-6">{{ "hello" | uppercase | text }}</h1>
<a class="submit-button" routerLink="/new">CREATE NEW HOTEL</a>
<app-search [(input)]="search"></app-search>
@if (hotels[0].hotelName) {

View file

@ -1,5 +1,5 @@
import { CommonModule, NgFor, NgIf, UpperCasePipe } from '@angular/common';
import { Component, inject } from '@angular/core';
import { Component, inject, ViewChild, ViewContainerRef } from '@angular/core';
import { TextPipe } from '../../text.pipe';
import { SearchComponent } from '../Search/search.component';
import { HotelService } from '../Parent/services/hotel.service';
@ -35,8 +35,19 @@ export class HotelListComponent {
public response: any = null;
public hotels: Array<Hotel> = [{} as Hotel];
@ViewChild('test2', { read: ViewContainerRef })
private test2ViewContainerRef!: ViewContainerRef;
constructor(private http: HttpClient) { }
async loadTest2() {
for (let i = 0; i < 1; i++) {
const { Test2Component } = await import('../test2/test2.component');
this.test2ViewContainerRef.createComponent(Test2Component);
}
}
ngOnInit() {
this.http.get<Array<Hotel>>('api/hotels').subscribe((res) => {
this.hotels = res;

View file

View file

@ -0,0 +1,6 @@
<iframe
src="https://funhtml5games.com?embed=flappy"
style="width: 800px; height: 520px; border: none"
frameborder="0"
scrolling="no"
></iframe>

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Test2Component } from './test2.component';
describe('Test2Component', () => {
let component: Test2Component;
let fixture: ComponentFixture<Test2Component>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Test2Component]
})
.compileComponents();
fixture = TestBed.createComponent(Test2Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-test2',
imports: [],
templateUrl: './test2.component.html',
styleUrl: './test2.component.css'
})
export class Test2Component {
}