import { Component , ComponentRef , Input , OnDestroy , OnInit } from '@angular/core' ; import { SearchResult } from '../models/search-result' ; import { NgbModal , NgbModalRef } from '@ng-bootstrap/ng-bootstrap' ; import { SearchResultPreviewComponent } from './search-result-preview.component' ; @ Component ( { selector : 'cmdb-search-result' , templateUrl : './search-result.component.html' , styleUrls : [ './search-result.component.scss' ] } ) export class SearchResultComponent implements OnInit , OnDestroy { @ Input ( ) searchResult : SearchResult = undefined ; private modalRef : NgbModalRef ; public constructor ( private modalService ) { } public ngOnInit ( ) { } public ngOnDestroy ( ) { if ( this . modalRef ) { this . modalRef . close ( ) ; } } public openPreview ( ) { this . modalRef = this . modalService . open ( SearchResultPreviewComponent , { size : 'lg' } ) ; this . modalRef . componentInstance . renderResult = this . searchResult . result ; } }