I am trying to upload an image and get it to display onscreen but it isnt working. Can anyone help? I was attempting to base my solution on this example: http://jsfiddle.net/kkhxsgLu/2/
View
<div class="col-sm-6">
Upload image:
<br><br>
<input id="file" type="file" accept="image/*" ng-model="file" ng-onchange="vm.imageUpload(this)"/>
<br>
<img ng-src="{{ file }}" />
</div>
Controller
var vm = this;
vm.file = {};
vm.imageUpload = function() {
var reader = new FileReader();
reader.onload = vm.imageIsLoaded;
reader.readAsDataURL(element.files[0]);
};
vm.imageIsLoaded = function(e) {
vm.$apply(function() {
vm.file = e.target.result;
})
}