kipris
kipris

Reputation: 3039

Angular validation: if dynamically add required attribute validation will break

Trying to dynamically add validation to input file if I choose first option from select. But if I add required attribute, it still ng-valid in class. If I load file to input file, it still ng-empty. What's wrong? http://plnkr.co/edit/pjyCULes60jWf7yqNsyB?p=preview

Upvotes: 0

Views: 362

Answers (1)

Nico
Nico

Reputation: 587

The form validation in AngularJS depends on the ngModel attribute, which doesn't work with input type=file.

To solve this, either use ngFileUpload which helps you solve other problems you'll encounter with file upload in Angular as well, or see this or that answer.

Upvotes: 1

Related Questions