【问题标题】:ng-switch causing error in uploadingng-switch 导致上传错误
【发布时间】:2016-06-20 11:09:09
【问题描述】:

我在此链接中使用了答案nodejs + multer + angularjs for uploading without redirecting 用于在 angularjs 中进行文件上传。 这非常有效。

根据我的要求,我编辑了angular html文件的代码(添加了ng-switch):

<div ng-switch="MyVar">

    <div ng-switch-when="car">
        <input type="file" file-model="myFile"/>
        <button ng-click="uploadFile()">Upload</button>
    </div>

    <div ng-switch-when="dog">
        dog
    </div>
</div>

所有其他文件完全相同。

ng-switch 工作正常。

但是在此更改之后,我的文件上传将无法正常工作(导致服务器错误,因为没有文件被发送)。 我的意思是,如果我删除链接中的开关部分,那么它工作正常。

$scope.myFile 即使在选择一个文件后也显示为空。

为什么 ng-switch 会导致问题?

请帮忙

【问题讨论】:

    标签: angularjs node.js file-upload ng-switch


    【解决方案1】:

    我认为 ng-switch 有自己的作用域。尝试使用file-model="$parent.myFile"。这个问题大概是相关的:angularjs - ng-switch does not bind ng-model

    【讨论】:

      猜你喜欢
      • 2013-12-27
      • 2017-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多