angularjs - File pick with Angular JS -


i pick file angularjs:

html:

<div ng-controller="topmenuctrl">     <button class="btn" ng-click="iscollapsed = !iscollapsed">toggle collapse</button>     <input type="file" ng-model="filepick" ng-change="pickimg()" multiple />     <output id="list"></output>  </div> 

javascript:

angular.module('plunker', ['ui.bootstrap']); function topmenuctrl($scope) {     $scope.pickimg = function() {         alert('a');     }; } 

how can bind input file onchange action on angularjs pickimg function? , how can manipulate files uploaded after?

angular doesn't yet support ng-change input[type=file] have roll onchange implementation yourself.

first, in html, define javascript onchange follows:

<input ng-model="photo"        onchange="angular.element(this).scope().file_changed(this)"        type="file" accept="image/*" /> 

and in angular controller code, define function:

$scope.file_changed = function(element) {       $scope.$apply(function(scope) {          var photofile = element.files[0];          var reader = new filereader();          reader.onload = function(e) {             // handle onload          };          reader.readasdataurl(photofile);      }); }; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -