ng-init在离子收集 - 重复块中不起作用

时间:2016-05-31 13:05:35

标签: angularjs collections ionic-framework repeat angularjs-ng-init

我正在使用以下视图:

<ion-item collection-repeat="scan in scans" href="#/app/scans/{{scan.local_id}}">
  <h2 class="media-heading">ID: {{(scan.id ? scan.id : '--')}}</h2>
  <div class="row">
    <div class="col">
      <div><b>Status</b></div>
      <div><b>Photos</b></div>
    </div>
    <div class="col">
      <div>{{getStatus(scan.status)}}</div>
      <div><span ng-init="setNumberOfPhotos(scan)" ng-bind="numberOfPhotos[scan.local_id]"></span></div>
    </div>
  </div>
</ion-item>

一切正常,控制器函数setNumberOfPhotos(scan)调用undefined值,我在控制台中看到错误:

TypeError: Cannot read property 'local_id' of undefined
    at Scope.setNumberOfPhotos (file:///android_asset/www/components/scans/scan.list.controller.js:83:35)

错误出现很多次,所以在每个循环中,但似乎ng-init在每个循环都没有被评估。有什么想法吗?

0 个答案:

没有答案