[英]Angular material ng-messages not appearing in dialog
I'm creating a log in form in a dialog and ng-messages for the respective input isn't appearing. 我正在对话框中创建一个登录表单,并且没有出现相应输入的ng-messages。 The validation is working correctly as the input is being highlighted red, and the button is disabled until the validation is correct.
验证工作正常,因为输入被突出显示为红色,并且按钮被禁用,直到验证正确。
The code for the dialog is is 对话框的代码是
<md-dialog-content>
<form name="signinForm" id="Signin" class="md-dialog-content">
<md-input-container class="flex-gt-sm">
<input type="email" required class="signInText" id="emailAddress" name="emailAddress" ng-model="signIn.emailAddress"placeholder="Email Address" ng-model="resetPassword.email" ng-pattern="/^.+@.+\..+$/" />
<div ng-messages="signinForm.emailAddress.$error" role="alert">
<div ng-message="pattern">
Please enter a valid email address
</div>
</div>
</md-input-container>
<br>
<md-input-container class="flex-gt-sm">
<input type="password" class="signInText" id="password" name="password" placeholder="Password" ng-model="signIn.password" />
</md-input-container>
<br>
<md-button class= id="resetPassword" style='text-align:center' onClick="resetPassword()">
Reset Password
</md-button>
<br>
<!-- Flat button with ripple -->
<md-checkbox ng-model="signIn.RememberMe" aria-label="Remember Me">
Remember Me
</md-checkbox>
<br>
<!-- Flat button with ripple -->
<md-button class= id="signIn" ng-disabled="signinForm.$invalid" style='text-align:center' ng-click="signIn()">
Sign In
</md-button>
<md-progress-circular class="md-hue-2 md-busy" ng-show="login.loading" md-mode="indeterminate" style="margin:auto"></md-progress-circular>
</form>
</md-dialog-content>
This is how I'm creating the dialog box 这就是我创建对话框的方式
$mdDialog.show({
controller: signInController,
templateUrl: 'signIn.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose:true,
})
My module is using ngMessages and if I put the loginform outside of a dialog box then the messages appear correctly. 我的模块正在使用ngMessages,如果我将loginform放在对话框之外,则消息会正确显示。
And I create my controller as a function. 我将控制器创建为一个功能。 There's not much in the controller yet
控制器中还没有多少
signInController($scope, $mdDialog, $log) {
}
If I put the html outside of a dialog and into a separate page it is working correctly. 如果我将html放在一个对话框之外并进入一个单独的页面,它就能正常工作。
I saw this was posted elsewhere 我看到这张贴在其他地方
Angular-material 1.1.0-rc has a known bug . Angular-material 1.1.0-rc有一个已知的bug 。 I noticed that you're using version 1.0.1 and you're probably experiencing the same bug.
我注意到你使用的是1.0.1版本,而且你可能遇到了同样的错误。
The bug shows the first error message and then won't display any future error messages, but the field will be highlighted red. 该错误显示第一条错误消息,然后不会显示任何将来的错误消息,但该字段将突出显示为红色。
Reproducing the bug in your case: 再现您案例中的错误:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.