import { Component , EventEmitter , Input , OnDestroy , OnInit , Output } from '@angular/core' ; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' ; import { LinkService } from '../../../services/link.service' ; import { Subscription } from 'rxjs' ; @ Component ( { selector : 'cmdb-object-link-delete-modal' , templateUrl : './object-link-delete-modal.component.html' , styleUrls : [ './object-link-delete-modal.component.scss' ] } ) export class ObjectLinkDeleteModalComponent implements OnInit , OnDestroy { @ Input ( ) public publicID : number = null ; @ Output ( ) public closeEmitter : EventEmitter < string > = new EventEmitter < string > ( ) ; private deleteSubscription : Subscription ; constructor ( public activeModal , private linkService ) { } public ngOnInit ( ) { this . deleteSubscription = new Subscription ( ) ; } public onDelete ( ) { this . deleteSubscription = this . linkService . deleteLink ( this . publicID ) . subscribe ( ( ) => { } ) . add ( ( ) => { this . activeModal . close ( ) ; this . closeEmitter . emit ( 'deleted' ) ; } ) ; } public ngOnDestroy ( ) { this . deleteSubscription . unsubscribe ( ) ; } }