HTML视图部分每次点击prev和next按钮时,viewCategory函数都可以工作:
<div class="subheader">
<ul class="categories">
<li ng-repeat="cat in categoryList" ng-class="{selected: cat.selected}">
<a ng-click="viewCategory(cat.name, cat._id)">{{cat.name}}</a>
</li>
<button class="arrow-left" ng-click="prevList($event)"></button>
<button class="arrow-right" ng-click="nextList($event)"></button>
</ul>
</div>
控制器部分:
$scope.nextList = function (e) {
var ele = e.target;
$(ele).parent().find('li.selected').removeClass('selected').next().addClass('selected').triggerHandler('click');
};
与prev功能相同 但触发器无效...... 请帮帮我.. 提前谢谢....
答案 0 :(得分:0)
答案 1 :(得分:0)
此时您正在触发li元素的点击。尝试:
$(ele).parent().find('li.selected').removeClass('selected').next().addClass('selected').find('a').triggerHandler('click');