'ng消息'没有在angular js中实例化

'ngMessages' not instantiated in angular js

本文关键字:js 实例化 angular ng 消息      更新时间:2023-09-26

下面是我的代码

   // LoginCtrl.js
angular.module('homeon', [ 'ngMessages' ]).controller('loginCtrl',
  function($rootScope, $scope, $state, $ionicLoading, dbservices, server) {
  //--------------------------------- my code-------------
})
<!-- login.html-->
<link href="css/login.css" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.4/cerulean/bootstrap.min.css">
<!-- load angular -->
<script src="http://code.angularjs.org/1.4.3/angular.js"></script>
<!-- load ngmessages -->
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-messages.js"></script>
<!-- load our custom app -->
<script src="js/loginCtrl.js"></script>
<body ng-app="homeon">
	<ion-view view-title="Login">
		  <ion-content>
		   <form name="loginForm" ng-submit="doLogin(loginForm)" novalidate="">
			   	<div class="list list-inset">
			   	<label class="item item-input itemLabel">
		        <input type="email" name="username" placeholder="Email" ng-model="username" required="required" ng-minlength="5" >
		        </label>
				<label class="item item-input itemLabel">
	            <input type="password" name="password" placeholder="Password" ng-model="password" required="required" pattern="(?=.*'d)(?=.*[a-z])(?=.*[A-Z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{8,}" autocapitalize="off" autocomplete="off" autocorrect="off">
	            </label>
				<div ng-messages="loginForm.username.$error" style="color:red; align:center">
					<span ng-message="required">Please enter user name</span>
					<span ng-message="minlength">Length of email must be minimum 5 characters</span>
					<span ng-message="email">Please enter valid email</span>
				<div>
				</div ng-messages="loginForm.password.$error" style="color:red; align:center">
					<span ng-message="required">Please enter password</span>
					<span ng-message="pattern">The passwords must be at least 8 characters and include an
		uppercase, lowercase, number, and special character</span>
				</div>
				<button type="submit" class="button button-block" ng-click="" >Login</button>
				</div>
			</form>
		  </ion-content>
</ion-view>
</body>

我在浏览器中收到"ngMessages"未实例化错误。你能告诉我我哪里做错了吗?或者为什么会出现这个错误?

提前谢谢。

在index.html页面中包含<script src="js/angular-messages.js"></script>