This commit is contained in:
2025-08-18 20:14:19 +03:00
parent 110615575e
commit 95654933ee
5 changed files with 26 additions and 32 deletions

View File

@@ -333,4 +333,15 @@
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<button (click)="this.sendRequest()">Send request</button>
@if(this.error){
<p>response:</p>
<p>{{ this.error }}</p>
}
@if (this.response) {
<p>response:</p>
<p>{{ this.response }}</p>
}
<router-outlet />

View File

@@ -1,29 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AppComponent],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it(`should have the 'IISA_web' title`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('IISA_web');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, IISA_web');
});
});

View File

@@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Component, inject } from '@angular/core';
import { RouterOutlet } from '@angular/router';
@Component({
@@ -9,4 +10,14 @@ import { RouterOutlet } from '@angular/router';
})
export class AppComponent {
title = 'IISA_web';
httpClient = inject(HttpClient);
response: any | null = null;
error: any | null = null;
sendRequest(){
this.httpClient.get('http://localhost:3000/app/candidates').subscribe({
next: (res) => this.response = JSON.stringify(res),
error: err => this.error = JSON.stringify(err)
})
}
}

View File

@@ -2,7 +2,8 @@ import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
import { provideHttpClient } from '@angular/common/http';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)]
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideHttpClient()]
};