0

我正在使用以下视图:

<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并没有在每个循环中进行评估。任何想法?

4

0 回答 0