Can somebosy please help me by telling how to use katex in angular 2 app?
I don't have any angular2 experience, but I found http://stackoverflow.com/questions/36370826/how-to-get-mathjax-working-with-angular2 which might help. Instead of calling
MathJax.Hub.Queue(["Typeset", MathJax.Hub, this.el.nativeElement]);
in ngOnChanges you'd call
katex.render("c = \\pm\\sqrt{a^2 + b^2}", this.el.nativeElement);
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: `<ng-katex [equation]="equation">`
})
export class AppComponent {
equation: string = ''\sum_{i=1}^nx_i'';
}
@garciparedes. Thanks a lot.
This sounds great! We should consider linking to this project from KaTeX.
Hi @edemaine, thank you very much. Do I make a pull request to the readme.md or do you prefer to be yours?
@garciparedes please open a pull request to a link to the README.md.
I made the changes in readme.md and opened the https://github.com/Khan/KaTeX/pull/959 pull request.
Most helpful comment
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:
To add the module to your proyect add the
KatexModuletoimport's field of your parent module:And then you can use it as follows: