具有Post请求的FileUpload指令

时间:2018-07-16 08:52:55

标签: javascript post file-upload angularjs-directive callback

我有一条指令将文件上传到SharePoint列表:

ExtraHeader.Add('<link rel="stylesheet" type="text/css" href="/css/mycustomcss.css">');

我有一个发布功能,可以将表单回复提交到同一列表。

指令实施:

app.directive('fileRead', fileRead);

function fileRead() {
    return {
        restrict: 'E',
        templateUrl: 'File-read.html',
        scope: {
            file: "=",
            upload: "=",
            prefix: "=",
            disablededit: "="

        },
        link: function (scope, element) { //attributes
            element.bind("change", function (changeEvent) {
                console.log('files bound');
                scope.$apply(function () {
                    console.log('files apply', scope);
                    scope.file = changeEvent.target.files[0];
                    console.log('files test', scope.file);
                });
            });

            scope.UploadFile = function () {
                if (scope.upload !== undefined && scope.disablededit !== undefined) {
                    if (scope.disablededit === false) {
                        scope.upload(scope.file);
                    }
                }
            };
        }
    };
}

但是<button type="submit" class="em-c-btn em-c-btn--primary" ng- click="IdeaForm.ideaBox.$valid && postIdeas(form); UploadFile();" ng- disabled='IdeaForm.ideaBox.$invalid'> <span class="em-c-btn__text">Submit</span> </button> <file-read file="Attachment" upload="UploadFile" disablededit="false"/> 不会在指令中执行。我该如何运作?

0 个答案:

没有答案