我有一个如下元素:
<a class="previous i-previous fa fa-caret-left" href=""
ng-click="setPage(currentPage-1)"
ng-hide="currentPage == 0">
</a>
我有这个代码工作,但现在我有这个例外:
错误:[$ parse:syntax] http://errors.angularjs.org/1.2.26/ $解析/语法P0 =未定义&安培; P1 =是%20unexpected%2C%20expecting%20%5B)%5D&安培; P2 = NULL&安培; P3 = setPage(当前页&安培; P4 = setPage(当前页
导致异常的代码是:
ng-click="setPage(currentPage-1)"
当我删除-1
时,它的工作原理似乎问题就在于那部分。
这种例外可能是什么原因?
编辑:
我的控制器中有这个代码:
$scope.currentPage = 0;
$scope.setPage = function (page) {
$scope.currentPage = page;
};
答案 0 :(得分:2)
It is caused by batarang in Chrome, disable it or use other browser to test, or use incognito mode.
答案 1 :(得分:1)
试试
ng-click="currentPage = currentPage - 1; setPage(currentPage)"
答案 2 :(得分:0)
它运行正常。检查小提琴
<div ng-app>
<div ng-controller="TodoCtrl">
<a href=""
ng-click="setPage(currentPage-1)"
ng-hide="currentPage == 0">test
</a>
</div>
</div>
function TodoCtrl($scope) {
$scope.currentPage = 5;
$scope.setPage = function (page) {
$scope.currentPage = page;
};
}