NetanelBasal
10/26/2018 - 12:56 PM

ace.directive.ts

let aceLoading = false;

@Directive({
  selector: '[appAce]'
})
export class AceDirective implements OnInit {

  constructor(private http: HttpClient, private host: ElementRef<HTMLElement>) {}

  ngOnInit() {
    this.waitForAce().subscribe(() => {
      window.ace.config.set('basePath', '/assets');
      this.editor = window.ace.edit(this.host.nativeElement);
    });
  }

  loadAce() {
    return this.http.get('/assets/ace.js', { responseType: 'text' });
  }
}