I have a file upload control in my form.I am using Angular JS . When I put the required attribute to validate that the file is selected it is not working.
&l
Extending @joakimbl code I will suggest the direct like this
.directive('validFile',function(){
return {
require:'ngModel',
link:function(scope,el,attrs,ctrl){
ctrl.$setValidity('validFile', el.val() != '');
//change event is fired when file is selected
el.bind('change',function(){
ctrl.$setValidity('validFile', el.val() != '');
scope.$apply(function(){
ctrl.$setViewValue(el.val());
ctrl.$render();
});
});
}
}
})
and in html you can use like this