diff --git a/src/app/pages/search/searchform/searchform.css b/src/app/pages/search/searchform/searchform.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/search/searchform/searchform.html b/src/app/pages/search/searchform/searchform.html new file mode 100644 index 0000000..422e005 --- /dev/null +++ b/src/app/pages/search/searchform/searchform.html @@ -0,0 +1,24 @@ +
+
+ + +
+
\ No newline at end of file diff --git a/src/app/pages/search/searchform/searchform.spec.ts b/src/app/pages/search/searchform/searchform.spec.ts new file mode 100644 index 0000000..fb917bb --- /dev/null +++ b/src/app/pages/search/searchform/searchform.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { Searchform } from './searchform'; + +describe('Searchform', () => { + let component: Searchform; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [Searchform] + }) + .compileComponents(); + + fixture = TestBed.createComponent(Searchform); + component = fixture.componentInstance; + await fixture.whenStable(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/search/searchform/searchform.ts b/src/app/pages/search/searchform/searchform.ts new file mode 100644 index 0000000..bdaf7b6 --- /dev/null +++ b/src/app/pages/search/searchform/searchform.ts @@ -0,0 +1,38 @@ +import { Component, inject, signal } from '@angular/core'; +import { Router } from '@angular/router'; +import { NasaApi } from '../../../interfaces/nasa-api'; +import { NAPOD } from '../../../services/napod'; + +@Component({ + selector: 'app-searchform', + imports: [], + templateUrl: './searchform.html', + styleUrl: './searchform.css', +}) +export class Searchform { + private readonly nasaApi = inject(NAPOD); + private readonly router = inject(Router) + searchResults = signal(null) + searchString=signal(''); + + onSubmit() { + this.nasaApi.searchForVideos(this.searchString()).subscribe({ + next: (data)=>{this.searchResults.set(data); + console.log(data.collection); + }, + error: error =>{console.log(error); + } + }) + } + + onClick(nasaId: string){ + this.router.navigate(['/video/'+nasaId]) + } + + updateSearch(event: Event){ + console.log(this.searchString()); + const target = event.target as HTMLInputElement; + this.searchString.set(target.value) + } + +}