Ankit Patidar Ankit Patidar - 5 months ago 102
AngularJS Question

ng-file-upload directive not working with ng-messages

I am using ng-file-upload directive to upload multiple mp3 files and want to apply validation for wrong file extention.

<div class="form-group" show-errors>
<label for="myfiles" class="control-label">{{constant.SELECT_FILE_OR_MULTIPLE_FILES}}:</label>
<input
type="file"
ngf-select
ng-model="series.myfiles"
name="myfiles"
id="myfiles"
ngf-max-size="100MB"
ngf-validate="{ pattern: '.mp3' }"
multiple

/>
<div ng-messages="form.talkForm.myfiles.$error" role="alert">
<p class="help-block error-text" ng-message="ngf-validate">{{constant.UPLOAD_TALK_ERROR}}</p>
</div>
</div>

Answer

As said in comment : the answer was that the field's name generated in the $error is not ngf-validate but depends of the type of validation.

Here it is a pattern match so the name of the error is pattern

Comments