【问题标题】:MathJax not working in Angular5 Div with observableMathJax 不能在 Angular5 Div 中使用 observable
【发布时间】:2018-01-28 00:30:38
【问题描述】:

我怎样才能使嵌套在我的 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 中的元素?

【问题讨论】:

    标签: angular typescript observable angular5 mathjax


    【解决方案1】:

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

    【讨论】:

    • 您能否详细说明如何执行此操作?
    • this.getRule('theorems').subscribe()
    • 为什么需要这个?
    • BibleComponent.html:8 ERROR Error: InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe'
    • 可能你不应该保存 bibleObservable: Observable;作为一个可观察的。只是bible : any[]。然后this.getRule(''theorems).subscribe( (res) =&gt; { this.bible = res } ) 将 Observables 视为管理 JS 承诺的一种可爱方式。
    猜你喜欢
    • 1970-01-01
    • 2018-09-15
    • 2021-08-10
    • 2018-07-06
    • 1970-01-01
    • 2018-08-21
    • 1970-01-01
    • 2018-07-21
    • 1970-01-01
    相关资源
    最近更新 更多