import {AfterViewInit, Component, ElementRef} from '@angular/core'; import {IOption} from 'ng-select'; declare var hljs: any; import {OptionService} from '../../services/option.service'; @Component({ selector: 'select-method', templateUrl: './select-method.component.html' }) export class SelectMethod implements AfterViewInit { characters: Array = this.optionService.getCharacters(); constructor( private elementRef: ElementRef, private optionService: OptionService ) {} ngAfterViewInit() { hljs.initHighlighting(); let nodes: NodeList = this.elementRef .nativeElement .querySelectorAll('.typescript, .html, .css'); for (let i = 0; i < nodes.length; i++) { hljs.highlightBlock(nodes[i]); } } html0: string = `
<ng-select
    #mySelect
    [options]="characters">
</ng-select>
<button
    (click)="mySelect.select('3')">
    Select Parzival
</button>
`; html1: string = `
<ng-select
    #mySelect
    [options]="characters"
    [multiple]="true">
</ng-select>
<button
    (click)="mySelect.select(['1', '3'])">
    Select Art3mis and Parzival
</button>
`; }