ng-file-upload在ng-repeat中不起作用

时间:2015-07-23 05:59:25

标签: javascript angularjs

我正在尝试将一个dropzone和file-upload按钮添加到一个部分中(此部分的每个单元格都有不同的参数)。 我使用danialfarid的angular-file-upload。 但是当我使用ng-repeat生成部分时,它根本不起作用,而当我在ng-repeat之外制作它时效果很好。

所以任何想法为什么$ scope.files都没有填充?

===

控制器:

angular.module('kapiyva').controller "ArticleEditController", ($scope, Upload, Shop, Item) ->

  $scope.$watch 'item.files', ->
    $scope.upload $scope.files
    return

  $scope.upload = (files) ->
    if files and files.length
      alert "ok"
      i = 0
      while i < files.length
        file = files[i]
        $scope.upload = Upload.upload(
          url: '/api/shops/1/items'
          method: 'POST'
          fields: 'item[shop_id]':'1'
          file: file
          fileFormDataName: 'item[image]')
        i++
      return

视图:

// ok
// (when $scope.$watch 'files', ->)
section
  p select file:
  input type="submit" value="select files" ngf-select="" ng-model="files"
  img ngf-src="files[0]" ngf-default-src="" ngf-accept="'image/*'"

// doesn't work if inside of ng-repeat...
section ng-repeat="item in shop.items"
  p select file:
  input type="submit" value="select files" ngf-select="" ng-model="item.files"
  img ngf-src="item.files[0]" ngf-default-src="" ngf-accept="'image/*'"

0 个答案:

没有答案