From 6b6c46b6c41812970e20409f052ce6004166ec34 Mon Sep 17 00:00:00 2001 From: maxime Date: Sun, 19 Apr 2026 11:42:38 +0200 Subject: [PATCH] added routerlink in search to open homepage from other pages whend searching --- src/app/pages/search/searchform/searchform.ts | 10 ++++++++-- src/app/shared/header/header.ts | 2 +- src/environments/environment.ts | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/app/pages/search/searchform/searchform.ts b/src/app/pages/search/searchform/searchform.ts index 3634e55..ce2e75c 100644 --- a/src/app/pages/search/searchform/searchform.ts +++ b/src/app/pages/search/searchform/searchform.ts @@ -1,11 +1,12 @@ -import { Component, inject, signal } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { NAPOD } from '../../../services/napod'; +import { Router, RouterLink } from '@angular/router'; import { Search } from '../../../services/search'; import { FormsModule } from '@angular/forms'; @Component({ selector: 'app-searchform', - imports: [FormsModule], + imports: [FormsModule, RouterLink], templateUrl: './searchform.html', styleUrl: './searchform.css', }) @@ -14,9 +15,14 @@ export class Searchform { private readonly searchService = inject(Search); searchString = this.searchService.searchString; + constructor(private readonly router: Router){ + + } + onSubmit(event: Event) { event.preventDefault(); // <-- EmpĂȘche le rechargement console.log("onSubmit appelĂ© !"); // <-- Devrait s'afficher + this.router.navigate(["/home"]) this.nasaApi.searchForVideos(this.searchService.searchString()).subscribe({ next: (data)=>{this.searchService.searchResults.set(data); console.log(data.collection); diff --git a/src/app/shared/header/header.ts b/src/app/shared/header/header.ts index 10f62fd..401a045 100644 --- a/src/app/shared/header/header.ts +++ b/src/app/shared/header/header.ts @@ -1,4 +1,4 @@ -import { Component, computed, input, signal, Signal } from '@angular/core'; +import { Component, computed, input } from '@angular/core'; import { Router, RouterLink } from '@angular/router'; import { Auth } from '../../services/auth'; import { Searchform } from "../../pages/search/searchform/searchform"; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index d740424..16b1629 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,3 +1,7 @@ export const environment = { - production: true + production: false, + NASA_API_BASE_URL : "", + NASA_API_KEY: '', + NASA_API_IMAGE_BASE_URL:'https://images-api.nasa.gov', + AUTH_API_BASE:'' };