使用Angular.js ng-file-upload上传错误文件时无法获取验证消息

时间:2016-03-05 04:15:29

标签: javascript angularjs ng-file-upload

我在尝试实现Angular.js的ng-file-upload时遇到了问题,我的问题是我在上传错误文件时没有收到任何验证消息。我在下面解释我的代码。

<form name="billdata" id="billdata"  enctype="multipart/form-data" novalidate>
   <div class="input-group bmargindiv1 col-md-12" ng-show="status==1">
        <div ng-class="{ 'myError': billdata.bannerimage.$touched && billdata.bannerimage.$invalid }">
        <div class="image-upload text-center">
        <label for="imagefile1">
        <img ng-src="{{attchImage1}}" style="cursor:pointer;width:auto; height:160px; border:1px #666 solid"/>
        </label>
<input type="file"  data-size="lg" name="bannerimage" id="imagefile1"  ng-model="file" ngf-pattern="image/*" accept="image/*" ngf-max-size="2MB" ngf-min-height="100" ngf-resize="{width:100, height:100}"   custom-on-change="uploadFile"  ngf-select="onFileSelect($file);" >
<div class="input-group bmargindiv1 col-md-12">
        <label for="imagefile1" >
        <span style="color:#00F; font-style:italic; cursor:pointer"> Click here to upload Image </span>
    <input type="hidden" name="someData" ng-model="imageData" />
      </label>
</div>

 </div>
 </div>

</div>
 <div class="help-block" ng-messages="billdata.bannerimage.$error" ng-if="billdata.bannerimage.$touched">
<p ng-message="maxSize" style="color:#F00;">File is too large.Max size is 2 mb.</p>
<p ng-message="minHeight" style="color:#F00;">Minimum height should be 100px</p>
</div>

</form>

当我上传错误的文件大小(i.e-min-height<100px)时,应显示验证错误消息,但它根本不会出现。请帮我解决此问题。

0 个答案:

没有答案