Having trouble getting ngAnimate to work properly?

I am facing an issue with ngAnimate dependency injection. For some reason, whenever I add ngAnimate as a dependency in my JavaScript code, it does not seem to work. It's definitely not the script...

Here is the HTML code snippet:

<!doctype html>
<html ng-app="myApp">
        <head>


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

            <script src="codebuttonewb.js"></script>

            <style>
                    .hidden{
                        display:none;
                    }
                    ul{
                    //display:flex;
                    margin-bottom:10px;
                     list-style-type: none;
                    }
                    li span{
                    display:inline-block;
                    line-height:50px;

                    }
                    li img{
                    margin-right:10px;
                    border-radius:50%;
                    width:50px;
                    height:50px;
                    }
            </style>
        </head>
        <body ng-controller="myController">
            <input type="text" ng-model="search" placeholder="search">
            <ul ng-class="{'hidden' : !toggle}"><!--  if this value is false then show the class of hidden -->
                <li ng-repeat="item in list | filter:search"
                    ng-class="item.age>29 ? 'over-thirty' : 'under-thirty'">

                    <img ng-src="{{item.img}}"/>
                    <span> {{item.name}} - <em>{{item.age}}</em></span>
                </li>

            </ul>
            <button ng-show="!toggle" ng-click="toggle=true" >show names</button>
            <button  ng-show="toggle" ng-click="toggle=false">hide names</button>
            <form ng-submit="addPerson()">

                    <input type="text" placeholder="name" ng-model="name"/>
                    <br/>
                    <input type="number" placeholder="age" ng-model="age"/>
                    <br/>
                    <input type="submit" value="submit" />

                </form>

        </body>

</html>

And here is the corresponding JavaScript code:

angular.module('myApp', ['ngAnimate'])
            .controller("myController",function($scope){


                $scope.toggle =true; 


                $scope.list=[
                {name:'bla',age:28,img: 'https://s3.amazonaws.com/uifaces/faces/twitter/brad_frost/128.jpg'},
                {name:'blabla',age:38,img: 'https://s3.amazonaws.com/uifaces/faces/twitter/mlane/128.jpg'},
                {name:'blaba',age:23, img:'https://s3.amazonaws.com/uifaces/faces/twitter/felipenogs/128.jpg'},
                {name:'blablala',age:56, img:'https://s3.amazonaws.com/uifaces/faces/twitter/adellecharles/128.jpg'}
                ];


                $scope.addPerson= function(){
                    $scope.list.push({name:$scope.name,age:$scope.age});
                    $scope.name="";
                    $scope.age="";
                };
            });

If anyone has a solution for this problem, I would greatly appreciate it. This is my first time working with ngAnimate, so I assume it might be something simple that I'm missing.

Answer №1

Having encountered similar challenges in the past, I recommend making the following adjustment:

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.js"></script>

Change it to:

<script src="https//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.js"></script>

Answer №2

If you want to utilize ngAnimate, make sure to incorporate CSS effects along with it. Here are some animation-css techniques that you can consider:

<div class="fade"></div>
<style>
/* The initial CSS styles for the enter animation */
.fade.ng-enter {
  transition:0.5s linear all;
  opacity:0;
}

/* The final CSS styles for the enter animation */
.fade.ng-enter.ng-enter-active {
  opacity:1;
}
</style>

ngAnimate will only apply ng-enter and ng-active classes. You will have to create your own CSS styles. In this example, I have used a fade effect.

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

Utilize Electron to extract and render content from a local file into HTML code

I am struggling to find a solution for automatically reading and parsing a local csv file in an electron application. When I use 'fs' to open the file, I can't figure out how to pass the contents into the HTML window. One option is to use a ...

Ways to conceal and reveal image and text elements based on array loop output

I am currently working on setting up a questionnaire. The questions and answer options are being pulled from a database using an API. Some of the options include images, with the image link stored in the database. I am trying to find a solution where text ...

javascript ondrag while self-pressing

Within this div, I have a series of p elements. My goal is to drag the selected element into the input field. Here's an example: var input = document.getElementById("test"); input.addEventListener('drop', function (event) { event.pr ...

"Troubleshooting a bug: GetElementById function fails to find elements with hyphenated

When calling attr('id') on an immutable id attribute for an HTML element, my code runs smoothly when the id contains no hyphens. However, it encounters issues when the id includes a hyphen. $('.coloursContainer .radio-box').live(' ...

In certain Express app files, the use of Sequelize modules may result in a return value of undefined

Objective - To implement a middleware-like callback in userHandler located in util.js for certain express routes in an express app, created using express-generator and sequelize-cli. Expected Outcome - Utilize the user model successfully in routes and use ...

What is the best way to combine this PHP, Javascript, and HTML document together?

My goal is to upload a CSV file exclusively using an HTML form and then save it in an array using PHP and Javascript. I have individual codes that work perfectly when used as separate files. However, when I attempt to combine them into one file, the Javas ...

Exploring the functionality of $timeout in AngularJS

Can you explain the functionality of $timeout in AngularJS and how it sets itself apart from traditional setTimeout()? ...

The validation function for email addresses in Express-validator seems to be malfunctioning

I've encountered an issue with the validation process in my code. Everything seems to be working fine except for the .isEmail method, which keeps flagging even valid email addresses as invalid. No matter how I adjust the validation rules, the problem ...

React Module cannot be found: Error: Unable to locate - import paths

New to coding and currently working on a website using React. Encountering three errors persistently: ERROR in ./src/Components/Pages1/Home.js 6:0-50 Module not found: Error: Can't resolve './Components/Cards/Cards1.js' in 'C:\Use ...

Empty array returned when using fetch in a for loop

Currently, I am developing a server route to execute API calls. I have encountered the need to make two separate fetch requests as I require additional information that is not available in the first fetch. The issue lies in declaring a variable outside o ...

Connect controls to elements within a sibling component

My ImagesInput component utilizes an array called images to display the images. I have added a button for changing the images, but I am facing an issue in separating and changing the correct image. It seems to only modify the last index of each gallery a ...

Finding the current div based on the scrolling position can be achieved without the use of jQuery

Seeking assistance with a coding challenge. I have a solution in jQuery, but we require the solution in plain JavaScript or Angular. It seems like something is missing. Take a look at this fiddle. The objective is to highlight the corresponding left panel ...

What are the steps to incorporating an Image in a React Native application?

My Image is not showing up when I try to render it using image uri, and I'm not sure why. Here is the code snippet I'm using in a React Native project. import React from 'react'; import styled from 'styled-components/native'; ...

Having trouble with ng-options not displaying in SELECT dropdown

Having some trouble getting the States to display correctly in a Select using ng-options. Being new to Angular, I'm not seeing the desired outcome. Controller $scope.statesList = function () { StatesList.query(function (states) { ...

Assigning an interface to a useFetch object in Vuejs 3 and Nuxtjs 3: A step-by-step guide

Need assistance with assigning an interface to a useFetch object in Vuejs 3 Interface export interface ProdutoInterface { codigo: number nome: string } Componente const { data: produto, error } = await useFetch(config.API_BASE_URL+`/produto`) I&apos ...

Is there a way to retrieve the ID value instead of the displayValue from md-autocomplete in my servlet?

For the past two weeks, I've been deep into learning angularjs. However, I've hit a technical roadblock with a seemingly simple issue that has me stumped. I'm trying to implement md-autocomplete in my project, but I can't seem to retrie ...

Concealing axis lines within the initial circular grid or opting not to include them

Is there a way to incorporate some whitespace within the center circle of the radar chart? I'm aiming for the axis to commence at 1 radius (the initial circular line) or perhaps have the stoke set to 0 for the primary radius. Any assistance would be g ...

When updating items in a FormView, the Dropdownlist may still hold the previous values

In a formview, there are two dropdownlists - one for cities and one for states. Whenever the state dropdownlist is changed, the city dropdownlist gets updated using javascript. If the city dropdownlist remains unchanged via javascript, the values of dlCi ...

Switch from using `widthWidth` to `useWidth` in MUI v5 ReactJS

Currently, I am in the process of updating a project that utilizes MUI as the UI Library for my React application. I have started migrating to version 5 today, and one issue I've encountered is related to all functional components wrapped by withWidth ...

Checking a sequence using a list of strings

I have an array containing a list of IDs: var listId: string[] = []; var newId: boolean; for (let i in data.chunk) { listId.push(data.chunk[i].aliases[0]); } My objective is to compare a new ID with the entire list. If the new ID is found in the list ...