问题描述
我想将普通验证放在基于角度的Crud表网格中..
我的代码适用于添加操作,但不适用于编辑操作,因为添加和删除我使用的是相同的型号.
我的添加代码如下:
<输入占位符="Group Name"必需ng-model ="grp.GroupName" name ="grpname" ng-init ="grp.GroupName =" Group Name" ng-maxlength ="100" ng-minlength ="3"/>
ng-show ="groupPage.grpForm.grpname.$ error.required&& groupPage.grpForm.grpname.$ dirty&!groupPage.grpForm.grpname.$ pristine">组名是必需的
ng-show ="groupPage.grpForm.grpname.$ error.minlength">组名太短.
ng-show ="groupPage.grpForm.grpname.$ error.maxlength">组名太长.
而编辑代码如下:-
{{grp.GroupName}}
< input placeholder ="Group Name"必需ng-model ="grp.GroupName" ng-show ="grp.editMode == true" name ="grpeditname" ng-maxlength ="100" ng-minlength ="3" />
{{grp.GroupName}}
ng-show ="groupPage.grpForm.grpeditname.$ error.required&& groupPage.grpForm.grpeditname.$ dirty&!groupPage.grpForm.grpeditname.$ pristine">组名是必需的
ng-show ="groupPage.grpForm.grpeditname.$ error.minlength">组名太短.
ng-show ="groupPage.grpForm.grpeditname.$ error.maxlength">组名太长.
用于编辑的代码不起作用其$ scope.Valid将作为false出现...在默认情况下应为true.
我对它进行了研究,发现由于grp.groupname ... groupname对于添加大小写是空的...并且当我进行编辑时,尽管edit groupname为nt null.在第二种情况下也将显示必需的字段验证器和最小最大长度错误.如何解决这种情况.
I want to put normal validation in crud table grid based on angular..
My code is working for add operation but not for edit one because for add and delete I am using the same modelname.
My code for add one is below:
<input placeholder="Group Name" required ng-model="grp.GroupName" name="grpname" ng-init="grp.GroupName=''Group Name''" ng-maxlength="100" ng-minlength="3" />
ng-show="groupPage.grpForm.grpname.$error.required && groupPage.grpForm.grpname.$dirty && !groupPage.grpForm.grpname.$pristine ">Group Name is Required
ng-show="groupPage.grpForm.grpname.$error.minlength">Group Name is too short.
ng-show="groupPage.grpForm.grpname.$error.maxlength">Group Name is too long.
And edit code is below:-
{{grp.GroupName}}
<input placeholder="Group Name" required ng-model="grp.GroupName" ng-show="grp.editMode == true" name="grpeditname" ng-maxlength="100" ng-minlength="3" />
{{grp.GroupName}}
ng-show="groupPage.grpForm.grpeditname.$error.required && groupPage.grpForm.grpeditname.$dirty && !groupPage.grpForm.grpeditname.$pristine">Group Name is Required
ng-show="groupPage.grpForm.grpeditname.$error.minlength">Group Name is too short.
ng-show="groupPage.grpForm.grpeditname.$error.maxlength">Group Name is too long.
The code for edit is not working Its $scope.Valid is coming as false...it should be true in default case.
I did research on it and found that its due to grp.groupname...groupname is empty for add case...and when i do edit it creating trouble though edit groupname is nt null..both falls in same form...Required field validator and min max length error is also nt displayed in second case..How to solve such case..
推荐答案
这篇关于如何在ng-repeat中放入角度Crud验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!