【问题标题】:TypeError: Cannot read property '$getIndex' of undefinedTypeError:无法读取未定义的属性“$getIndex”
【发布时间】:2015-08-21 10:40:24
【问题描述】:

我需要一些有关如何摆脱此错误的帮助。

TypeError: Cannot read property '$getIndex' of undefined
  at Scope.<anonymous> (angularfire.min.js:1)
  at Parser.filter.fnInvoke (angular.js:10101)
  at OPERATORS.| (angular.js:9616)
  at Parser.binaryFn.extend.constant (angular.js:10046)
  at OPERATORS.| (angular.js:9616)
  at Parser.binaryFn.extend.constant (angular.js:10046)
  at OPERATORS.| (angular.js:9616)
  at Parser.binaryFn.extend.constant (angular.js:10046)
  at Object.$watchCollectionWatch (angular.js:11726)
  at Scope.$get.Scope.$digest (angular.js:11890)

【问题讨论】:

  • 请更具体,分享您的代码并正确描述您的问题。谢谢。

标签: javascript angularjs


【解决方案1】:

您需要等待数据加载完毕。像这样的

$scope.data.$on('loaded', function() {
  console.log($scope.data.$getIndex());
}); 

等待loaded 事件,然后尝试使用$getIndex()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-24
    • 2019-08-19
    • 1970-01-01
    相关资源
    最近更新 更多