尝试使用Angular.js显示验证消息时出错
Getting error while trying to display validation message using Angular.js
我在尝试使用Angular.js.显示验证消息时遇到以下错误
错误:
angularjs.js:107 Error: [$parse:syntax] http://errors.angularjs.org/1.4.6/$parse/syntax?p0=%7B&p1=is%20an%20unexpected%20token&p2=17&p3=billdata.upload_%7B%7BNaNndex%7D%7D.%24touched&p4=%7B%7B%index%7D%7D.%24touched
我在下面解释我的代码。
<div class="input-group bmargindiv1 col-md-12" ng-repeat="mul in mulImage">
<span class="input-group-addon ndrftextwidth text-right" style="width:180px">Image{{$index+1}}:</span>
<div>
<div ng-class="{'myError': billdata.upload_{{$index}}.$touched && billdata.upload_{{$index}}.$invalid }">
<input type="file" class="filestyle form-control" data-size="lg" name="upload_{{$index}}" id="bannerimage_{{$index}}" ng-model="mul.image" ngf-pattern="'image/*'" accept="image/*" ngf-max-size="2MB" ngf-min-height="400" ngf-resize="{width: 400, height:400}" ngf-select="onFileSelect1('upload_{{$index}}',mul.image);">
<div style="clear:both;"></div>
</div>
</div>
<span class="input-group-btn" ng-show="mulImage.length>0">
<img ngf-thumbnail="mul.image" name="pro" border="0" style="width:32px; height:32px; border:#808080 1px solid;">
<input type="button" class="btn btn-success" name="plus" id="plus" value="+" ng-click="addNewImageRow(mulImage);" ng-show="$last"> <input type="button" class="btn btn-danger" name="minus" id="minus" value="-" ng-show="mulImage.length>1" ng-click="deleteNewImageRow(mulImage,$index);">
</span>
<div class="help-block" ng-messages="billdata.upload_{{$index}}.$error" ng-if="billdata.upload_{{$index}}.$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 400px</p>
</div>
</div>
在这里,当我添加这个验证消息<div class="help-block" ng-messages="billdata.upload_{{$index}}.$error" ng-if="billdata.upload_{{$index}}.$touched">
时,它抛出了上面的错误。请帮助我解决此错误。
我将使用"billdata['upload_' + $index].$error
而不是"billdata.upload_{{$index}}.$error
您可以将ng-if="billdata.upload_{{$index}}.$touched"
更改为ng-if="billdata['upload_'+this.$index].$touched"
。和ng-messages
的相同变化
相关文章:
- 可以't识别验证消息的源代码
- Jquery验证消息更改(自定义消息集)
- 如何使用 javascript 警报窗口显示验证消息
- RadEditor 验证消息仅在回发后发送
- 尝试使用Angular.js显示验证消息时出错
- 表单验证消息(使用jQuery验证插件)
- javascript form validaton, 验证消息 快速消失.
- 重置表单后未删除验证消息
- 显示Javascript表单验证消息
- Angular.js验证消息未显示
- 如何一起显示验证消息
- Kendo UI网格自定义验证消息
- 在屏幕上显示 JavaScript 验证消息,而不是警报消息
- 钩子 jQuery 验证消息更改
- 如何在 mvc 中更改验证消息的样式
- Yii2 - i18n 表示 js 验证消息中的 {属性}
- 角度验证消息不适用于 ng-show 和两个输入
- 如何使用 jquery 清除单个验证消息
- 如何在登录验证中自定义验证消息位置
- 显示基于多个条件的带有 ng 消息的验证消息