我已经实施了emailPattern
方法来验证特定的电子邮件地址,因此当我的模态窗口弹出时,我会看到以下错误,如何解决angularjs中的$digest
错误?
main.html中
<md-input-container flex="100">
<label>Cc</label>
<md-chips ng-model="notifyCtrl.cc" name="email"
md-separator-keys="customKeys"
md-transform-chip="addChips($chip)"
md-add-on-blur='true'
ng-pattern="emailPattern($chip)"
name="email">
</md-chips>
<div class="help-block" ng-messages="notifyForm.email.$error" ng-show="notifyForm.email.$touched && notifyForm.email.$invalid">
<div ng-message="pattern">An email must contain a-z, A-Z, 0-9, or _ characters.</div>
</div>
</md-input-container>
Ctrl.js
$scope.emailPattern = function(elementValue){
var emailPattern = /^[a-z]{2}[0-9]{3}[a-z0-9]+@[a-zA-Z0-9.]+\.[a-zA-Z]{2,4}$/;
console.log(emailPattern.test(elementValue));
return emailPattern;
}
错误
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [[{"msg":"emailPattern($chip)","newVal":{},"oldVal":{}}],[{"msg":"emailPattern($chip)","newVal":{},"oldVal":"..."}],[{"msg":"emailPattern($chip)","newVal":{},"oldVal":"..."}],[{"msg":"emailPattern($chip)","newVal":{},"oldVal":"..."}],[{"msg":"emailPattern($chip)","newVal":{},"oldVal":"..."}]]