Angular JS throwing error: 'ngMessages' not initialized

Here is the code snippet I am working with:

   // 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 encountered an error saying 'ngMessages' not instantiated in the browser. Can someone please assist me in identifying where my mistake lies or why this error is occurring?

Appreciate your help in advance.

Answer №1

Make sure to add

<script src="js/angular-messages.js"></script>
to your index.html file

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can one quickly display a confirmation dialog box within react-admin?

Looking for a way to implement a confirmation dialog in my react-admin project, similar to JavaScript's alert function but more visually appealing. I want the user to only proceed with certain database operations if they click OK on the dialog. I cou ...

issue with accessing property in vue 2 simple examination

Hey there! I'm currently working on implementing Vue in a Laravel application, but I've run into some challenges. Essentially, my goal is to retrieve data from a GET request and generate results based on that data. However, I'm struggling to ...

Problems Arising from the Combination of Django and External JavaScript

I am currently working on a project that uses Django 1.11 and JavaScript, but I am encountering an issue. The JavaScript code works fine when run within the HTML file, as it successfully loads the JSON data. However, when I move everything to the static fo ...

Trouble with modifying style in Google Chrome and Internet Explorer prior to AJAX request

When utilizing AJAX, I have a common practice of setting up a loading indicator before each request to inform the user about the short wait. Usually, this is achieved by adding an animated loading gif. Interestingly, when performing this action in Firefox, ...

Issue with Guild Member Add functionality in discord.js is not functioning as expected

I'm facing an issue with my code where the bot does not send a welcome message when a user joins, despite having everything set up correctly. Even when a user leaves, there is no farewell message being sent either. Here is the code I am using: bot.on ...

Forcing an iframe in an ASP.NET web application to refresh and reload

Although I have experience in .NET Core development, ASP.NET Web Apps are new territory for me. Within my Index.cshtml, there is an iframe with the following attributes: <iframe height="800" width="1300" loa ...

Unable to navigate using single-page navigation due to JavaScript malfunction

I'm struggling with this particular code and I'm hoping for some assistance. My experience with javascript is limited, so I'm reaching out for help instead. I am trying to implement the jquery single.page.nav feature that enables navigation ...

API Post request encountering fetch failure

The route "/api/users/register" on my express server allows me to register an account successfully when passing data through Postman. However, when trying to register an account using the front-end React app, I'm encountering a "TYPE ERROR: Failed to ...

Challenges when it comes to exporting files using Firebase Cloud Functions

I've been working with Firebase Cloud Functions using JavaScript, but I'm encountering issues with the import and export statements. Is there a solution to replace them? const firebase = require('firebase'); const config = { apiKe ...

What is the method for causing ui-mask to send the $viewValue back to the model rather than the $modelValue?

Utilizing the ui-mask feature on an input field for date entry: <input type="text" ui-mask="19/39/2999" ng-model="inicio"> (the 1, 3 and 2 are additional masks I included to restrict input to 0-1, 0-3, and 2-3, respectively) An issue arises when ...

Placing a MongoDB query results in an increase of roughly 120MB in the total JS heap size

I'm puzzled by the fact that the heap size increases when I include a MongoDB database query in a function within my controller. Here is the code for my router: import { Router } from "express"; import profileController from '../contro ...

Resetting a form field in JavaScript when clicked

Apologies in advance for the beginner question! I'm currently developing a Calculator app in JavaScript and struggling to make the "C" (clear) button clear the field completely. EDIT: Just to be clear, I want the Clear button to not only clear the fie ...

Updating React JSX class based on certain conditions without manipulating the actual DOM

When working with jsx react, I am looking to dynamically set a class while keeping another class static. Here is an example of what I would like to achieve: maintaining the type class and having an additional dynamic class change change to either big, smal ...

Filtering an array using criteria: A step-by-step guide

Currently, I am developing a system for Role Based permissions that involves working with arrays. Here is an example of the array structure I have: let Roles = { [ { model: 'user', property: 'find', permission: 'allow' ...

Is there a way to convert an array into a single comma-separated value using parameters?

Is there a way to parameterize an array as a single name-value pair that is comma separated? I have tried using jQuery $.param, but it creates a parameter for each value in the array instead of just one. Unfortunately, it seems that there is no option or s ...

bulk purchase discount with HTML/JavaScript/PHP

I am looking to add a slider feature to my "Prices" page in order to provide customers with an instant quote based on the quantity they select. The slider should range from 1 to 500 or even up to 1000, but having an input box for customers to enter the qu ...

Achieving a smooth transition from a blur-out effect to a blur-in effect on a background Div

I created a blur in/out effect for my landing page, but it's not functioning as expected and I'm not sure why. It blurs out correctly, but the issue arises when I want the underlying Div to fade in. Currently, it just appears abruptly after the ...

Capturing mouse coordinates from hover events in Highcharts Gantt using the highcharts-react library

Currently, I am utilizing the official React highcharts wrapper to create a Gantt chart. My goal is to obtain precise mouse coordinates from a mouse-over event and utilize them for a custom tooltip. For instance: https://stackblitz.com/edit/react-c5mivs ...

Tips for extracting variables from a get OData call function

Is there a better approach to retrieving variables from a GET OData call? I'm struggling with extracting the 'id' variable from the call within my method. I've tried using callbacks, but have not been successful. Do you have any suggest ...

Exploring Karma-coverage: Customizing color choices and exclusion settings

Currently, we are incorporating karma-runner with coverage. The generated report automatically assigns colors green, yellow, and red based on preset thresholds. I am interested in customizing these thresholds to better suit our project requirements. In ad ...