journal-notes.component.ts 762 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { Component, OnInit, OnDestroy } from '@angular/core';
  2. import { Editor } from 'ngx-editor';
  3. import { marked } from 'marked';
  4. @Component({
  5. selector: 'app-journal-notes',
  6. templateUrl: './journal-notes.component.html',
  7. styleUrl: './journal-notes.component.scss',
  8. })
  9. export class JournalNotesComponent implements OnInit, OnDestroy {
  10. editor: Editor = new Editor();
  11. html = '';
  12. markdownString =
  13. ' # Hello \n \
  14. this is a test \
  15. **hi** \
  16. \
  17. - 1\
  18. - 2';
  19. htmlString = '';
  20. constructor() {
  21. this.htmlString = marked(this.markdownString);
  22. console.log(this.markdownString);
  23. console.log(this.htmlString);
  24. }
  25. ngOnInit(): void {}
  26. // make sure to destory the editor
  27. ngOnDestroy(): void {
  28. this.editor.destroy();
  29. }
  30. }