我正在尝试验证textAngular文件,我需要添加必需的,最大和最小字符和textAngular上的红色/绿色边框颜色...我有for each循环和inide textAngulars...
下面是我的代码:
<form ng-submit="addReply(x)" class="dd animated slideInDown" novalidate>
<div class="form-group">
<text-angular ng-minlength=10 ng-maxlength=600 required ta-text-editor-class="form-control myform1-height" ta-html-editor-class="form-control myform1-height" ta-toolbar="[['bold','italics']]" style="min-height: 100px; color:red;" ng-model="form.reply[x.pivot.comment_id]"></text-angular>
<span ng-show="form.reply[x.pivot.comment_id].$dirty && form.reply[x.pivot.comment_id].$invalid"></span>
<span ng-show="form.reply[x.pivot.comment_id].$error.min || form.reply[x.pivot.comment_id].$error.max">
The value must be in range 0 to 10!</span>
<span ng-show="form.reply[x.pivot.comment_id].$error.required">Email is required.</span>
</div>
<div class="form-group">
<addreply></addreply>
</div>
</form>我的代码不能工作我不知道为什么..。
发布于 2015-09-21 04:06:33
根据AngularJS文档,您的表单和输入应该有名称。然后,您应该将验证ng-show设置为form_name.input_name.$error等等,就像here一样
发布于 2015-09-21 12:57:21
这是一个基于您的问题的小示例
validating the required fieldhttp://plnkr.co/edit/6PTNg3atPHAjL0XFtvWj?p=info
https://stackoverflow.com/questions/32683470
复制相似问题