Angular cli mathjax

Viewed 491

Angular 4.0 npm install mathjax for node_module, add "scripts": ["./node_modules/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"], to angular-cli.json and addtypes": ["mathjax"],` to tsconfig.app.json

but error say "MathZoom.js and MathMenu.js not found". How to deal with this problem...... thanks!!!!!!

1 Answers

To add MathJax into Angular 4 application, simply add the below lines in index.html and do the following steps.

<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script>
<!-- MathJax Implementation -->
  <script type="text/x-mathjax-config">
        MathJax.Hub.Config({
         showProcessingMessages: false,
         tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] }
        });
    </script>

HTML code where you want to render the formula

<div class="mathjax" >{{Formula}}</div>

TS file where you want to apply mathjax

let mathjax=document.getElementsByClassName('mathjax');
       eval('MathJax.Hub.Queue(["Typeset",MathJax.Hub, mathjax])');
      eval('MathJax.Hub.Queue(["Typeset",MathJax.Hub, mathjax])');
Related