how to use animation with ng-repeat in angularjs

前端 未结 4 877
一生所求
一生所求 2020-12-08 14:00

I have a list which I iterate over by using ng-repeat: and the user can interact with thte list items by using up-arrow and down-arrow icons and on click of them i simply ch

4条回答
  •  鱼传尺愫
    2020-12-08 14:24

    Following on from Marcel's comment: in AngularJS 1.2 you don't need to use the ng-animate directive. Instead:

    1. Includeangular-animate[-min].js.
    2. Make your module depend on ngAnimate.
    3. Define your transitions in CSS using classes like .ng-enter and .ng-enter-active.
    4. Use ng-repeat as you normally would.

    HTML:

    • {{item}}

    JavaScript:

    angular.module('foo', ['ngAnimate']);
    // controllers not shown
    

    CSS:

    li {
        opacity: 1;
    }
    li.ng-enter {
        -webkit-transition: 1s;
        transition: 1s;
        opacity: 0;
    }
    li.ng-enter-active {
        opacity: 1;
    }
    

    Demo in (someone else's) Plunker.

    See the docs for $animate for details on the progression through the various CSS classes.

提交回复
热议问题