I am using Angular UI Router with MathJax. When I route to a new state, the MathJax does not get processed. What burns my noodle is that if I have an update button with exactly the same code it works. Just not by itself.
HTML
<p id="MathExample"><strong>Equation:</strong> {{data.equation}}</p>
<button class="btn btn-primary" ng-click="update()">Update</button>
JS
$stateProvider.state('route1', {
url: "/route1",
templateUrl: "route1.html",
controller: function($scope, $http){
$http({method: 'GET', url: 'data.json'})
.success(function(data) {
$scope.data = data;
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
//You would think that the value would be updated here!
})
$scope.update = function($scope){
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
//This works just fine, but is not automatic.
}
}
});
I'm trying to figure out why this is the case. Do I need to use $apply? One question hinted at the use of a directive. However, I don't need this function. I really just need the JSON data with the math expressions to reliably become typeset.