Angular Terminal

Angular Terminal

·

1 min read

Angular Terminal is a text based user interface. Enter "date" to display the current date.

Setup

Refer to PrimeNG setup documentation for download and installation steps for your environment.

Import

import {TerminalModule} from 'primeng/terminal';

Getting Started

Commands are processed using observables via the TerminalService. Import this service into your component and subscribe to commandHandler to process commands by sending replies with sendResponse function.

<p-terminal welcomeMessage="Welcome to PrimeNG" prompt="primeng $"></p-terminal>
import {Component} from '@angular/core';
import {TerminalService} from 'primeng/components/terminal/terminalservice';

@Component({
    template: '<p-terminal welcomeMessage="Welcome to PrimeNG" prompt="primeng $"></p-terminal>',
    providers: [TerminalService]
})
export class TerminalDemo {

    constructor(private terminalService: TerminalService) {
        this.terminalService.commandHandler.subscribe(command => {
            let response = (command === 'date') ? new Date().toDateString() : 'Unknown command: ' + command;
            this.terminalService.sendResponse(response);
        });
    }
}

Theming

Terminal supports various themes featuring Material, Bootstrap, Fluent as well as your own custom themes via the Designer tool.

Resources

Visit the PrimeNG Terminal showcase for demos and documentation.