Angular 1.4 and using ngAnimate with JavaScript

I'm trying to set up an ngAnimate .animation()

script on Angular 1.4, but I'm struggling with the basics as this should display a warning, but it doesn't:

.animation('.animated', function () {
     // should display an alert here...
     alert('hello ?');
})

      

I need to be missing something, but can't figure out what. Here is a jsfiddle .

Many thanks for your help.

+3


source to share


2 answers


<div ng-app="MyApp">
    <div ng-controller="MyCtrl">
        <input type="checkbox" ng-model="checked" style="float:left; margin-right:10px;" /> Is Visible...
        <span class="animatedsomething" ng-show="checked">Hello {{who}}.</span>
    </div>
</div>

      

and



angular.module('MyApp', ['ngAnimate'])
.controller('MyCtrl', function ($scope) {
    $scope.who = 'World';
})
.animation('.animatedsomething', function () {
       // should display an alert here...

    alert('hello ?');

});

      

seems to generate a warning. I do not know why. Quoting from https://docs.angularjs.org/guide/animations "AngularJS 1.3 provides animation hooks for common directives like ngRepeat, ngSwitch and ngView, as well as custom directives via the $ animate service." Maybe you need one of these directives for the animation to be applied.

0


source


The animation is triggered using one of the Docs directives described here . For example ngClass

. Demo .



<div ng-app="MyApp">
    <div ng-controller="MyCtrl">
        <span ng-class="{animated: true}">Hello {{who}}.</span>
    </div>
</div>

      

+1


source







All Articles