0

My requirement is user runtime input should be converted to Matjax format I tried as follows

script

var app=angular.module('app',[]);

app.run(function($rootScope){
  $rootScope.$watch(function(){
    MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
    return true;
  });
});

app.controller('math',function($scope){
   $scope.update = function() {
       $scope.Expression = $scope.mathtext;
         MathJax.Hub.Queue(["Typeset",MathJax.Hub]);     
   }
   $scope.Expression = 'Evaluate: `( 5/4 div 1/6 )`';
});

Html

<!DOCTYPE html>
<html>

  <head>
    <link rel="stylesheet" href="style.css">
    <script data-require="angular.js@1.4.8" data-semver="1.4.8" src="https://code.angularjs.org/1.4.8/angular.js"></script>
    <script async   src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=AM_HTMLorMML-full.js">    </script>
    <script src="script.js"></script>
  </head>

  <body ng-app="app">
    <div ng-controller="math">
        <input type="text" ng-model="mathtext" ng-change="update()"/>
        <div id="mathjaxtext">{{Expression}}</div>
    </div>
  </body>

</html>

Demo

Expected result when user type

What is the value of 5/8 and `6/9 it should show as follows

What is the value of 5/8 and 6/9 mathjax format

But what I get is What is the value of 58 and 69(54÷16)

I don't want to use the directory for solving this issue.

5/8(54÷16) (the previous value also preserve in this how to get only the user typed content get converted?

Thirumalai murugan
  • 5,698
  • 8
  • 32
  • 54
  • Possible duplicate of [Getting MathJax to update after changes to AngularJS model](https://stackoverflow.com/questions/16087146/getting-mathjax-to-update-after-changes-to-angularjs-model) – Peter Krautzberger Sep 25 '17 at 16:45
  • Have you looked at https://stackoverflow.com/a/29908748/1339651? – Peter Krautzberger Sep 25 '17 at 16:46
  • @PeterKrautzberger its slightly different than the https://stackoverflow.com/questions/16087146/getting-mathjax-to-update-after-changes-to-angularjs-model mine is uses the input text to update the model – Thirumalai murugan Sep 26 '17 at 05:50

0 Answers0