Newbie to Angular. Very straightforward question. I have the following code.
I just want to show the file count underneath. I bind the fileCount variable to scope, but it doesn't work.
var app = angular.module('fileUploader', []);
app.controller('upload', function($scope){
$scope.fileCount = 0;
})
.directive("customDirective", function(){
return{
link: function(scope, el, attrs){
el.bind("change", function(event){
console.log(event.target.files.length);
scope.fileCount = event.target.files.length;
});
}
}
});
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
</head>
<body>
<div ng-app="fileUploader" ng-controller="upload">
<input custom-Directive type="file"/>
<p>The file count is: {{fileCount}}</p>
</div>
</body>