Angularjs 更新指令中的ng repeat对象属性

Angularjs 更新指令中的ng repeat对象属性,angularjs,angularjs-directive,Angularjs,Angularjs Directive,我有一份清单,上面有来自JSON的多个问题: <div class="tab-pane fade in active" id="tab1"> <div class="row"> <div class="col-sm-12"> <h3>{{list.titel}}</h3> <table class="table table-striped table-respons

我有一份清单,上面有来自JSON的多个问题:

 <div class="tab-pane fade in active" id="tab1">
    <div class="row">
       <div class="col-sm-12">
          <h3>{{list.titel}}</h3>

          <table class="table table-striped table-responsive">
            <tr ng-repeat="question in list.questions">
                <td>{{question.label}}</td>
                <td ng-if="question.checkboxes.length > 0">
                    <div class="form-check" ng-repeat="checkbox in question.checkboxes">
                        <input type="checkbox" class="form-check-input" ng-model="checkbox.value">
                            <label class="form-check-label">{{checkbox.text}}</label>
                    </div>
                </td>

                <td ng-if="question.checkboxes.length < 1">
                    <input type="text" ng-model="question.value" class="form-control">
                </td>
            </tr>
          </table>
         </div>
      </div>
     </div>
该指令返回图像的路径。 我想将图像存储在问题列表的JSON结构中。 但我怎么知道这张照片是在哪个问题上拍摄的呢?
是否有存储位置的方法,例如:
列表。问题[4]。imagepath

这应该适合您。将模型解析为指令并设置新的对象属性

看法
你的
数据在哪里?我的指令
指令?@lin,对不起,是“我的指令”指令。你救了我的周末!
<div>
    <input type="text" ng-model="question.remark" class="form-control"> <br>
    <input type="file" ng-model="question.image" class="form-control" my-directive>
</div>
.directive('dataMyDirective', function (httpPostFactory) {
        return {
            restrict: 'A',
            scope: true,
            link: function (scope, element, attr) {

                element.bind('change', function () {
                    var formData = new FormData();
                    formData.append('file', element[0].files[0]);
                    httpPostFactory('php/saveUpload.php', formData, function (callback) {
                       // recieve image name to use in a ng-src 
                        console.log(callback);
                    });
                });

            }
        };
    })
    .factory('httpPostFactory', function ($http) {
        return function (file, data, callback) {
            $http({
                url: file,
                method: "POST",
                data: data,
                headers: {'Content-Type': undefined}
            }).then(function (response) {
                callback(response);
            });
        };
    });
<input type="file" 
       ng-model="question.image" 
       base-model="question" 
       class="form-control" 
       my-directive>
.directive('dataMyDirective', function (httpPostFactory) {
    return {
        restrict: 'A',
        scope: {
            baseModel: '='
        },
        link: function (scope, element, attr) {

            element.bind('change', function () {
                var formData = new FormData();
                formData.append('file', element[0].files[0]);
                httpPostFactory('php/saveUpload.php', formData, function (callback) {
                    // recieve image name to use in a ng-src
                    console.log(callback);

                    scope.baseModel.fileName = callback.whatEverFileNameIs;
                    scope.apply();
                });
            });

        }
    };
})