How to get Mathjax working with Angular2?

前端 未结 4 858
春和景丽
春和景丽 2020-12-16 03:34

Has anyone gotten Mathjax working with Angular2 ?

Plunkr example created :- http://plnkr.co/edit/FLduwmtHfkCN5XPfzMsA?p=preview

From some Angular1 example

4条回答
  •  情话喂你
    2020-12-16 04:17

    Based on this question, I started the development of an open source project to typeset TeX math expressions with Angular. The project is on https://github.com/garciparedes/ng-katex.

    You can install the module with:

    npm install ng-katex --save
    

    To add the module to your proyect add the KatexModule to import's field of your parent module:

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { AppComponent } from './app/app.component';
    
    import { KatexModule } from 'ng-katex';
    
    @NgModule({
      imports: [BrowserModule, KatexModule],
      declarations: [AppComponent],
      bootstrap: [AppComponent]
    })
    
    class AppModule {}
    
    platformBrowserDynamic().bootstrapModule(AppModule);
    

    And then you can use it as follows:

    import { Component } from '@angular/core';
    
    @Component({
      selector: 'my-app',
      template: ``
    })
    export class AppComponent {
      equation: string = ''\sum_{i=1}^nx_i'';
    }
    

提交回复
热议问题