MathJax无法在Angular5 Div中使用observable

时间:2018-01-28 00:30:38

标签: angular typescript observable angular5 mathjax

我怎样才能使我的div中嵌套的元素可以被MathJax更改为从TeX转换为HTML。

目前我有这个app.component.html:

<p>
  When \(a \ne\) It works baby
</p>
<div class="topnav">
  <input type="text" placeholder="Search..">
<div class="theoremsContainer">
  <ul>
    <div *ngFor="let theorem of bibleObservable | async">
      <ngb-alert type="info" [dismissible]="false">
        <h1>{{theorem.rule}}: {{theorem.name}}</h1>
        <p>{{theorem.eq}}</p>
      </ngb-alert>
    </div>
  </ul>
</div>
</div>

顶部的段落标记格式正确,但是嵌套在带有ngFor标记的div中的定理未正确显示,而只显示TeX。作为参考,这是我的app.component.ts:

import { Component, OnInit } from '@angular/core';
import { AngularFireDatabase } from 'angularfire2/database';
import { Observable } from 'rxjs/Observable';

@Component({
  selector: 'app-bible',
  templateUrl: './bible.component.html',
  styleUrls: ['./bible.component.scss']
})
export class BibleComponent implements OnInit {

  bibleObservable: Observable<any[]>;

  constructor(private db: AngularFireDatabase) { }

  ngOnInit() {
    this.bibleObservable = this.getRule('/theorems');
  }

  getRule(listPath): Observable<any[]> {
    return this.db.list(listPath).valueChanges();
  }

}

如何使MathJax也改变嵌套在这个div中的元素?

1 个答案:

答案 0 :(得分:1)

您是否有正确的订阅来获取这些值?我的意思是,对于每个Observable.subscribe()?