求教 Angular2 怎样使用动画

2016-03-24 10:47:52 +08:00
 musicq

angular2 怎样使用动画模块

import {Component,ElementRef,Renderer} from 'angular2/core';
import {AnimationBuilder} from 'angular2/animate';

@Component({
    selector: 'app-animate',
    templateUrl: `
      <h1 #h1>hello</h1>
      <button (click)="start(h1,button)" #button>开始动画</button>
    `,
    providers: [AnimationBuilder]
})

export class AnimateComponent {

    constructor(public _animationBuilder:AnimationBuilder,
                public _renderer:Renderer) {

    }

    start(h1:HTMLElement, button:HTMLElement) {

        let origText = button.innerHTML;

        this._renderer.setText(button, '动画中..');

        this._animationBuilder
            .css()
            .addClass('animated')
            .setDuration(5000)
            .addAnimationClass('bounce')
            .start(h1)
            .onComplete(() => {
                this._renderer.setText(button, origText);
            });
    }
}

网上看的这个例子一直报错,就是 providers 这个属性造成的,如果去掉就不会有报错,所以应该怎样写,求教大神!!!!

3161 次点击
所在节点    Angular
1 条回复
musicq
2016-03-24 11:36:10 +08:00
折腾一上午,终于找到解决方案了!!!真捉急

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/265966

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX