2

I want to upload a file to my server, but I want the trigger to be an image. I constructed an example to test the base functionality, but it isn't responding the way I was expecting. The window launches properly, but I will eventually want to fire the code in a function after the file has been selected, and I can't get the function in the controller to fire from ng-change.

HTML:
<div ng-controller="myCtrl">
    <div class="choose_file">
        <img src="http://upload.wikimedia.org/wikipedia/commons/a/ae/Landscape_in_the_Adirondacks_Frederic_Edwin_Church.jpg" style="height: 300px; width: 400px"></img>
        <input ng-model="someRandomValue" type="file" ng-change="trigger()" />
    </div>
</div>


Controller:
myApp.controller('myCtrl', function($scope) {
    $scope.trigger = function() {
        alert("Changed");
    };
});

I don't see any issues in the logic, but the alert never pops up. See fiddle for full code.

C1pher
  • 1,933
  • 6
  • 33
  • 52
  • 1
    possible duplicate of [AngularJs: How to check for changes in file input fields?](http://stackoverflow.com/questions/17922557/angularjs-how-to-check-for-changes-in-file-input-fields) – lucuma Apr 10 '14 at 20:05
  • @lucuma Foiled by the AngularDocs again. Thank you for linking to this answer. – C1pher Apr 10 '14 at 20:10

0 Answers0