I have a directive that places a file upload input field on the DOM, and I then want the ability to call a function when that file is changed. How can I get an on change function to work without placing it in the compiler area? I know it doesn't belong there, as I've been told the compiler is more memory intensive and should only be used for pre-render stuff.
angular.module('myApp').directive('customDirective', ['$http', function ($http) {
return {
controller() {
},
compile(element) {
const $fileinput = $('<input type="file" accept=".csv">').appendTo(element);
return {
controller: () => {
$fileinput.on('change', (e) => {
// Stuff happens
});
},
link: () => {
},
};
},
};
}]);