frontend-tutorial-framework/src/app/terminal/terminal.component.ts

33 lines
842 B
TypeScript

// Copyright (C) 2018 Avatao.com Innovative Learning Kft.
// All Rights Reserved. See LICENSE file for details.
import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { TerminadoService } from '../services/terminado.service';
@Component({
selector: 'app-terminal',
templateUrl: './terminal.component.html',
styleUrls: ['./terminal.component.scss']
})
export class TerminalComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild('xterm', {static: true}) target: ElementRef;
constructor(private terminadoService: TerminadoService) { }
ngOnInit() {
}
ngAfterViewInit() {
this.terminadoService.attach(this.target.nativeElement as HTMLElement);
}
ngOnDestroy() {
this.terminadoService.detach();
}
fit() {
this.terminadoService.fit();
}
}