我正在尝试使用AngularJS验证cshtml中的输入控件。它不适用于CSHTML,但它在普通的HTML页面中有效。有什么方法可以解决这个问题吗?
我的代码如下:
<form ng-app novalidate ng-submit="addRow()">
<div class="control-group" ng-class="{true: 'error'}[submitted && form.email.$invalid]">
<label class="col-md-2 control-label" for="email">Email</label>
<div class="col-md-4">
<input type="email" name="email" class="form-control" ng-model="email" required />
<span class="text-danger" ng-show="submitted && form.email.$error.required">Required</span>
<span class="text-danger" ng-show="submitted && form.email.$error.email">Invalid email</span>
</div>
</div>
</div>
答案 0 :(得分:0)
//try this
<form name="myForm" novalidate ng-submit="addRow()">
<label class="col-md-2 control-label" for="email">Email</label>
<div class="col-md-4">
<input type="email" name="email" class="form-control" ng-model="email" required />
<span data-ng-show="myForm.email.$error.required && (myForm.email.$dirty || submitted)" class="help-block">Required.</span>
</div>
</form>