TypeError:无法读取属性' next'在AngularJS中未定义

时间:2015-05-26 08:09:57

标签: javascript jquery angularjs

HTML:

<a href="#" ng-click="next()" class="timeline-right-arrow" tabindex="0">
    <i class="timeline-right-arrow-icon"></i>
  </a>

JavaScript的:

$scope.next = function () {
  $scope.timeLineScroll.next();
};

$scope.prev = function () {
  $scope.timeLineScroll.prev();
};

点击next时出现此错误:

TypeError: Cannot read property 'next' of undefined
    at Scope.$scope.next (TimelineController.js:139)
    at $parseFunctionCall (angular.js:12404)
    at angular-touch.js:472
    at Scope.$get.Scope.$eval (angular.js:14466)
    at Scope.$get.Scope.$apply (angular.js:14565)
    at HTMLAnchorElement.<anonymous> (angular-touch.js:471)
    at HTMLAnchorElement.jQuery.event.dispatch (jquery.js:3074)
    at HTMLAnchorElement.jQuery.event.add.elemData.handle (jquery.js:2750)

TimelineController.js 139.line

1 个答案:

答案 0 :(得分:0)

在这一行$scope.timeLineScroll.next()中,您的$ scope.timeLineScroll未定义,这就是它抛出此错误的原因。