angular2 怎样使用动画模块
import {Component,ElementRef,Renderer} from 'angular2/core'; import {AnimationBuilder} from 'angular2/animate'; @Component({ selector: 'app-animate', templateUrl: ` <h1 #h1>hello</h1> <utton (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
这个属性造成的,如果去掉就不会有报错,所以应该怎样写,求教大神!!!!
![]() | 1 musicq OP 折腾一上午,终于找到解决方案了!!!真捉急 |