I'm trying to use ng-model on input element with file type. I've found this example but still dunno how to turn it to ES6 and use it (put it to ng-model or sth).
var myApp = angular.module('myApp', []);
myApp.directive('customOnChange', function() {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var onChangeFunc = scope.$eval(attrs.customOnChange);
element.bind('change', onChangeFunc);
}
};
});
myApp.controller('myCtrl', function($scope) {
$scope.uploadFile = function(){
var filename = event.target.files[0].name;
alert('file was selected: ' + filename);
};
});