import { Component , OnInit } from '@angular/core' ; import { ImageApiService , APIResult , ImageResult } from '../image-api.service' ; @ Component ( { selector : 'app-image-search' , templateUrl : './image-search.component.html' , styleUrls : [ './image-search.component.css' ] } ) export class ImageSearchComponent implements OnInit { searchTerm = '' ; loading = false ; images : string [ ] = [ ] ; constructor ( private imageAPIService ) { } ngOnInit ( ) { } formSubmitted ( ) { this . images = [ ] ; this . loading = true ; this . imageAPIService . getImages ( this . searchTerm ) . subscribe ( ( images ) => { this . images = images ; this . loading = false ; } ) ; } }