i want to upload multiple files using angular js, but it is like limited number of files and each with specific validation, hence cant use multiple. Using multiple controls one for each file..
below is the sample code
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.filelist = ['file1','file2']
});
app.directive(fileBind, function() {
return function( scope, elm, attrs ) {
elm.bind(change, function( evt ) {
scope.$apply(function() {
scope[ attrs.fileBind ] = evt.target.files;
});
});
};
});
the corrposponding html is:
<div ng-controller=MainCtrl>
<div ng-repeat=myfile in filelist>
<input type=file file-bind=files />
</div>
<div ng-repeat=file in files>
<pre>{{ file | json }}</pre>
</div>
</div>
I have also made a plunker for it:
http://plnkr.co/edit/DF2WYU
but this is not working... if i use $index or anything to store all the files uploaded, the directive stops working...
any help is appriciated