From 95654933eec4221ff423cc532da2dc0c90f30335 Mon Sep 17 00:00:00 2001 From: Vasa Date: Mon, 18 Aug 2025 20:14:19 +0300 Subject: [PATCH] WIP --- angular.json | 2 +- src/app/app.component.html | 11 +++++++++++ src/app/app.component.spec.ts | 29 ----------------------------- src/app/app.component.ts | 13 ++++++++++++- src/app/app.config.ts | 3 ++- 5 files changed, 26 insertions(+), 32 deletions(-) delete mode 100644 src/app/app.component.spec.ts diff --git a/angular.json b/angular.json index 5c36fd4..f0cb141 100644 --- a/angular.json +++ b/angular.json @@ -17,7 +17,7 @@ "build": { "builder": "@angular-devkit/build-angular:application", "options": { - "outputPath": "dist/iisa-web", + "outputPath": "./dist/iisa_web", "index": "src/index.html", "browser": "src/main.ts", "polyfills": [ diff --git a/src/app/app.component.html b/src/app/app.component.html index 36093e1..7073f36 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -333,4 +333,15 @@ + +@if(this.error){ +

response:

+

{{ this.error }}

+} +@if (this.response) { +

response:

+

{{ this.response }}

+} + + diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts deleted file mode 100644 index c620562..0000000 --- a/src/app/app.component.spec.ts +++ /dev/null @@ -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'); - }); -}); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index fb6b082..27363b6 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -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) + }) + } } diff --git a/src/app/app.config.ts b/src/app/app.config.ts index a1e7d6f..94f5f50 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -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()] };