3

Trying to upload an image file and process it in an AngularJS function called onFileSelect. However after the Choose File button was clicked the value of $scope.fileMsg inside onFileSelect was not updated. Any tips? Thanks a bunch!

<div ng-app="myApp" ng-controller="myCtrl">
    <form name="myForm">
        <div>
            <input type="file" ngf-select="onFileSelect(file)" name="file">
            <span ng-show="fileMsg">{{fileMsg}}</span>
        </div>
    </form>
</div>
<script>
   var app = angular.module('myApp', []);
   app.controller('myCtrl', function($scope, $http) {
        $scope.fileMsg = "Checkpoint 1";
        $scope.onFileSelect = function(file) {
        $scope.fileMsg = "Checkpoint 2";
        }
    }
);
</script>

1 Answer 1

2

You have to insert the 'ngFileUpload' in the module, like this:

var app = angular.module('myApp', ['ngFileUpload']);

And, if you haven't already, inject the necessary scritps.

Here is a working Fiddle: http://jsfiddle.net/ADukg/23032/

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I was able to make it after adding the ngFileUpload. I also needed to download a copy of ng-file-upload.js and include it in the HTML. Cheers :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.