在 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>