Mr. Noddy
Mr. Noddy

Reputation: 1590

'ngMessages' not instantiated in angular js

Following is my code

   // 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>

I am getting 'ngMessages' not instantiated error in browser. Can you please let me know where am I doing wrong or why I am getting this error?

Thanks in advance.

Upvotes: 1

Views: 1427

Answers (1)

Mayur Panchal
Mayur Panchal

Reputation: 26

Include <script src="js/angular-messages.js"></script> In your index.html page

Upvotes: 1

Related Questions