Enhancing the functionality of angular-messages is impacting the overall design of

Displaying here is the current state of my login form:

https://i.sstatic.net/EMcjF.png

However, subsequent to upgrading angular-message to version 1.4 and higher, the layout transforms into this:

https://i.sstatic.net/vVBHf.png

Sharing my source code for reference:

<ion-view view-title="Login">
    <ion-header-bar class="bar-calm">
      <h1 class="title">Login</h1>
    </ion-header-bar>

    <ion-content class="padding">
        <form name="signinForm" novalidate="">
            <div style="line-height: 250px; background-color: rgb(255, 255, 255); border: 1px solid rgb(238, 238, 238); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; text-align: center; width: 100%; height: auto;">
                <i class="icon ion-image" style="font-size: 64px; color: rgb(136, 136, 136); vertical-align: middle;"></i>
            </div>
            <div class="list">
                <label class="item item-input"
                    ng-class="{'has-error' : signinForm.email.$invalid && signinForm.email.$dirty,
                    'valid-lr' : signinForm.email.$valid  && signinForm.email.$dirty}">
                    <span class="input-label">Email</span>
                    <input type="email" 
                        name="email"
                        placeholder="Email" 
                        ng-model="data.email" 
                        required>
                </label>
                <div class="form-errors" 
                  ng-show="signinForm.email.$error && signinForm.email.$dirty"
                  ng-messages="signinForm.email.$error" 
                  ng-messages-include="templates/form-errors.html">
                </div> 

                <label class="item item-input"
                    ng-class="{'has-error-lr' : signinForm.password.$invalid  && signinForm.$submitted, 'valid-lr' : signinForm.password.$valid  && signinForm.$submitted}">
                    <span class="input-label">Password</span>
                    <input type="password" 
                        name="password"
                        placeholder="Password" 
                        ng-model="data.password"
                        ng-minlength="5">
                </label>
                <div class="form-errors" 
                   ng-show="signinForm.password.$error && signinForm.password.$dirty"
                   ng-messages="signinForm.password.$error"
                   ng-messages-include="templates/form-errors.html">
                </div>

            </div>
            <div class="spacer" style="height: 0px;"></div>
            <button class="button button-calm button-block icon-left ion-android-social-user" ng-click="login()" ng-disabled="signinForm.$invalid">Login</button>
            <a href="#/signup" class="button button-positive button-clear button-block ">Not a memeber? Create an account</a>
       </form>
    </ion-content>
</ion-view>

What might be triggering this change in layout? Seeking advice or suggestions. Thanks.

Answer №1

In order for the ng-message directive to function properly, it should be nested within the ng-messages directive. Otherwise, it may not work as expected on the same element. The Angular version used does not impact the functionality after 1.2.18+. An example is provided below:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular-messages.js"></script>

<script>
  angular.module('foo', ['ngMessages']);
</script>

<script>
function bop(model, view)
 {
 var i = 0, len = 100000, buz = "";
 
 for (i; i < len; i++)
   {
   buz = buz.concat(i);
   }
  
 bop.cache.put('listContent', buz);
 view.loaded = true;
   
 return model;
 }

 function baz($templateCache)
   {
   bop.cache = $templateCache;
   
   return bop;
   }

 baz.$inject = ['$templateCache','$rootScope'];

 angular.module('foo').filter('baz', baz);
</script>

<div ng-app="foo">
  <form name="myForm">
  <label>Check Me<input type="checkbox" ng-model="$root['required']"></label>
  <div ng-include="'listContent' | baz:myForm"></div>
  <div ng-messages="$root" style="color:green" role="alert">
    <div ng-message="required">👯</div>
  </div>
  <div ng-messages="myForm">
    <div ng-message="loaded" style="color:blue">Loaded</div>
  </div>
    
</div>

compared to:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-messages.js"></script>

<script>
  angular.module('foo', ['ngMessages']);
</script>

<script>
function bop(model, view)
 {
 var i = 0, len = 100000, buz = "";
 
 for (i; i < len; i++)
   {
   buz = buz.concat(i);
   }
  
 bop.cache.put('listContent', buz);
 view.loaded = true;
   
 return model;
 }

 function baz($templateCache)
   {
   bop.cache = $templateCache;
   
   return bop;
   }

 baz.$inject = ['$templateCache','$rootScope'];

 angular.module('foo').filter('baz', baz);
</script>

<div ng-app="foo">
  <form name="myForm">
  <label>Check Me<input type="checkbox" ng-model="$root['required']"></label>
  <div ng-include="'listContent' | baz:myForm"></div>
  <div ng-messages="$root" style="color:green" role="alert">
    <div ng-message="required">👯</div>
  </div>
  <div ng-messages="myForm">
    <div ng-message="loaded" style="color:blue">Loaded</div>
  </div>
    
</div>

References

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 I turn off Angular Grid's virtualization feature, where Angular generates div elements for the grid based on height and width positions?

Currently, I am working with an Angular grid (ag-grid) that dynamically creates div elements in the DOM to display data as the user scrolls or views different sections. As part of my testing process using Selenium WebDriver, I need to retrieve this data fr ...

Connect two radio buttons across separate forms

I am encountering an issue with two radio buttons that I am trying to link together. The problem arises because they are located in two separate form elements, causing them not to function as intended. It is important for the forms to be utilized in Bootst ...

Proper positioning of popover ensures it does not exceed the boundaries of its parent

In my ngprime table, the header row contains a column field with a popover set to display at the top. However, it is covering the actual field instead of appearing above it. This issue arises because the popover cannot display outside of its parent div, ca ...

AngularJS - Issue with ng-mouseover not triggering controller function

I am struggling to get a function to trigger when my button is hovered over. Despite writing what I believe is the correct code, the function from my controller is not being called. Can anyone spot the issue? Below is the JavaScript code: angular.module( ...

What are the steps to incorporate Redux into an Angular 9 application?

While implementing redux in my app, I encountered an error stating: The required dependencies for the entry-point "@angular-redux/store" are not present: - redux - redux-devtools-extension Any advice on how to resolve this issue? ...

Tips for displaying a refresh indicator while making an ajax call for refreshing data:

I have successfully implemented jQuery code that refreshes a specific div every 10 seconds without reloading the entire page. However, during this refresh process, the user does not visually perceive any changes happening in the browser. While there are n ...

Could you please explain the mysterious space that appeared between padding-bottom and border-bottom?

I noticed a very subtle orange gap between the padding-bottom and border-bottom. What could be causing it? https://i.sstatic.net/7eFXw.png Below is the code snippet in question: p { border-bottom: 1px solid #E8E8E8; margin: 0 auto; padding-botto ...

Creating a progress bar with a circular indicator at the completion point

Looking to create a unique horizontal progress bar with a circle at the end using react js, similar to the image provided. Successfully implemented a custom "%" progress bar and now aiming to incorporate a circle with text inside at the end. To view the c ...

AuthGuard in Ionic 4 causing delay in page routing permissions

In my ionic 4 app, I store user information natively. The goal is to direct users to the Home Page if their information is already stored when they open the app. If not, they should be routed to the Login Page - pretty standard procedure. However, the iss ...

Navigating with Angular Material and md-nav-bar for efficient routing

Currently, I am delving into Angular and have opted to utilize the Angular Material library for my initial application. After tweaking some basic code borrowed from this source, which I adjusted to suit my requirements, I encountered difficulties with rout ...

Using Bootstrap to create a floating image amidst surrounding elements

<div id="wrapper"> <div class="row"> <div class="col-sm-6 col-xs-12 image">Image</div> <div class="col-sm-6 col-xs-12 title">Title</div> <div class="col-sm-6 col-xs-12 description"> Desc ...

Tips on adjusting a position that shifts with changes in window size

Working on a website for my grandpa, I'm planning to include a small biker character that runs across the screen. When hovered over, he stops and advises "wear a helmet." The animation works well, but there's an issue with the positioning when th ...

Guide to setting up a node.js server that serves HTML files with CSS styling

I am currently working on setting up a simple node.js server for my HTML using http and express. Everything is functioning properly, but the CSS is not displaying as expected. Here is the code snippet for my server setup: const express = require("express ...

By utilizing the <tr> element, one can enhance the border thickness by 1 pixel

Is it possible to ensure that row selection in a table is consistent in terms of border alignment on both sides? https://i.stack.imgur.com/qmZiQ.png If you have any suggestions or solutions, please share them. Thank you! table { margin: 10px; bord ...

What is the default delay when utilizing the $timeout function in AngularJS?

While looking at the concise information on the AngularJS $timeout documentation page, I noticed that the 'delay' argument is listed as optional. However, when utilizing $timeout without specifying a delay, I observed that a delay is still implem ...

What is the functionality of CSS radio tabs?

Can anyone provide a breakdown of how the final section of this code operates? Specifically: [type=radio]:checked { } [type=radio]:checked ~ .content { z-index: 1; } I am brand new to CSS and wanted to experiment with creating interactive CSS tabs, whi ...

Guide on aligning svg and button horizontally while maintaining vertical alignment

I found this interesting code snippet: .float-left { float: left !important; } .float-right { float: right !important; } .container { padding: 1rem; } .clearfix { clear: both; } .has-border { border: 2px solid #000; } .d-inline-block { ...

Click to reveal additional images once the "show more" button is pressed

Hey there! I'm currently working on implementing a feature where, upon clicking "show more", 3 images will be displayed. And if the user clicks again, another set of 3 images will appear, and so on. I seem to be facing some difficulties with the JavaS ...

Modify the parent div's style if there are more than two children present (CSS exclusive)

Is there a way to use the same class, like .outer, for both divs but with different styling for the parent element when there are more than two children? Kindly refer to the example provided below: .outer1{ border: solid 6px #f00; } .outer2{ b ...

Challenges with Table and <p> Spacing in HTML and CSS

My website is centered around tables. The body section of my site aligns with the bottom of the header nav bar. However, when I begin typing text in the body, it shifts down by a few pixels. Here are some examples: Before typing any text: After entering ...