为什么 AngularJS 分页无法在下一页加载 KaTeX?

Why AngularJS pagination is not able to load the KaTeX in the next page?

在 AngularJS 分页中,我使用 KaTeX JavaScript 数学方程库。

问题:当我转到下一页分页时,库不工作。请帮助我理解,我做错了什么? 这是我的 app.js 和 index.html 代码。 这是我的app.js。

var app = angular.module('app', ['ngRoute', 'bw.paging', 'paging', 
'katex']);  
app.controller('homeCtrl', ['$scope', '$http', function($scope, $http)
{  
$scope.yo= {  
    'opted' : '',  
}  
$scope.var = 7;  
$scope.equations = [{'name' : 'Integration', 'notation' : '\(k_{n+1} 
= n^2 + k_n^2 - k_{n-1}\)'},  
                    {'name' : 'Summation', 'notation' : 
'90${}^\circ$'},  
                    {'name' : 'Union', 'notation' : '\(ax^2 + bx + c 
= 0\)'},  
                    {'name' : 'integration', 'notation' : 
'$f(x)=a_0+\int^{\infty }_{n=1}{(a_n{\mathrm{cos} \frac{n\pi x}
{L}\ }+b_n{\mathrm{sin} \frac{n\pi x}{L}\ })}$'},  

];  
  $scope.submitTest = function(questions){  
        var marks =0;  
        for(var i =0;i < questions.length; i++){  
            console.log(questions[i].opted);  
            console.log('hi');  
            if(questions[i].correct_options == questions[i].opted)
                marks = marks +1;  
        }  
        console.log(marks);  
    };  


$scope.currentPage = 0;  
$scope.pageSize = 1;  
$scope.data = [];  
$scope.q = '';  


$scope.numberOfPages=function(){  
    return Math.ceil($scope.equations.length/$scope.pageSize);                  
}  


}]);  

//We already have a limitTo filter built-in to angular,  
//let's make a startFrom filter  
app.filter('startFrom', function() {  
    return function(input, start) {  
        start = +start; //parse to int  
        return input.slice(start);  
    }  
  });  

this is my index.html  
 <div ng-repeat="item in equations | filter:q | 
  startFrom:currentPage*pageSize | limitTo:pageSize">  
      <katex auto-render ng-bind="item.notation"></katex>  
    </div>  
    <button ng-disabled="currentPage == 0" ng-
 click="currentPage=currentPage-1">  
        Previous
    </button>  
    {{currentPage+1}}/{{numberOfPages()}}  
    <button ng-disabled="currentPage >= equations.length/pageSize - 1" 
 ng-click="currentPage=currentPage+1">  
        Next
    </button>  

这里的问题是文档对象没有重新呈现。 你可以试试这个自动渲染。 https://github.com/Khan/KaTeX/tree/master/contrib/auto-render

否则,请尝试使用 katax 与 angularJS 的示例摘录。 http://lucasbardella.com/blog/2014/11/katex-angularjs

为了在不刷新页面的情况下动态呈现数学方程式,我使用了 MathJax 的主处理队列。使用 MathJax.Hub.Queue() 将回调推送到此队列。

app.directive('mathjax',function(){
return {
    restrict: 'EA',
    link: function($scope, attrs) {
        $scope.$watch(attrs.ngModel, function () {
            MathJax.Hub.Queue(['Typeset',MathJax.Hub]);
        });
     }
   };
});