Firepad with Angular

848 Views Asked by At

I would like to use firepad within my angular application.

I don't see any example of firepad with angular 5.

I am not sure how to bind .ts to html. Sample example with .html and .ts file would be a great help.

Thanks Pari

1

There are 1 best solutions below

0
On BEST ANSWER

Answering my own question:

Typescript

import { Component, OnInit, ViewChild } from '@angular/core';

import { AceEditorComponent } from 'ng2-ace-editor';
import * as Firepad from 'firepad';
import * as firebase from 'firebase';

@Component({
  selector: 'app-request-access',
  templateUrl: './request-access.component.html',
  styleUrls: ['./request-access.component.css']
})
export class RequestAccessComponent implements OnInit {
  @ViewChild('firepad') firepadEle: AceEditorComponent;
  constructor() { }

  ngOnInit() {
    let editor = this.firepadEle.getEditor();
    let firepad = Firepad.fromACE(firebase.database().ref(), editor);
  }

}

HTML

<ace-editor
#firepad
mode="java"
theme="eclipse"
[options]="options"
[readOnly]="false"
[autoUpdateContent]="true"
class="ace-editor"
style="height:150px;">
</ace-editor>

We just have to use AceEditorComponent in html and use it in typescript.