import {Component, ElementRef} from '@angular/core'; declare var hljs: any; @Component({ selector: 'faq', templateUrl: './faq.component.html' }) export class Faq { question1: string = 'I pushed new options to my options array, why do they not appear in the drop down list?'; question1html: string = `
<ng-select
[options]="myOptions"
</ng-select>
`;
question1tsNotWorking: string = `
this.myOptions = [];
ngOnInit() {
this.optionsService.loadOptions().subscribe((options) => {
options.forEach((option) => {
this.myOptions.push(option);
});
});
}
`;
question1tsWorking: string = `
this.myOptions = [];
ngOnInit() {
this.optionsService.loadOptions().subscribe((options) => {
this.myOptions = options;
});
}
`;
constructor(
private elementRef: ElementRef,
) {}
ngAfterViewInit() {
hljs.initHighlighting();
let nodes: NodeList = this.elementRef
.nativeElement
.querySelectorAll('.typescript, .html, .css, .shell-session');
for (let i = 0; i < nodes.length; i++) {
hljs.highlightBlock(nodes[i]);
}
}
goTo(location: string): void {
window.location.hash = '';
window.location.hash = location;
}
}