1

I used the answer in this link nodejs + multer + angularjs for uploading without redirecting for making file uploads in angularjs. This works perfectly.

According to my requirements i edited the code of angular html file (added 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>

All the other files are exactly same.

ng-switch works correctly.

But after this change my file upload wont work (causes server error because no file gets send). I mean if i remove the switch part as in the link then it works fine.

$scope.myFile shows null even after selecting a file.

Why is ng-switch causing problem?

please help

Community
  • 1
  • 1
Gaurav Gupta
  • 1,929
  • 4
  • 21
  • 40

1 Answers1

1

I think the ng-switch makes its own scope. Try using file-model="$parent.myFile". This question is probably related: angularjs - ng-switch does not bind ng-model

Jason Livesay
  • 6,317
  • 3
  • 25
  • 31