简体   繁体   English

Angular 2 AoT编译器动画回调错误

[英]Angular 2 AoT compiler animations callback error

I have Component defined like this: 我有像这样定义的组件

@Component({
    moduleId: module.id,
    templateUrl: 'my.template.html',
    animations: [
      trigger('fadeInOut', [
        state('in', style({opacity: 1})),
        transition('void => *', [
            style({
                opacity: 0
            }),
            animate(500)
        ]),
        transition('* => void', [
            animate(500, style({
                opacity: 0
            }))
        ]),
    ])
  ]
})
export class MyComponent implements OnInit, OnDestroy {
    public stage: number = 0;
    ...
    transitionDone(transitionEvent: any): void {...}
    ...
}

And template looking like this: 和模板看起来像这样:

<div
    *ngIf="stage"
    @fadeInOut
    (@fadeInOut.done)="transitionDone($event)"
></div>

App works fine when using JIT compilation, and done callback is fired correctly, but when i try to compile it using ngc (v. 0.6.0) it gives mi an error: 应用程序在使用JIT编译时工作正常,并且正确地触发回调,但是当我尝试使用ngc(v.6.0.0)编译它时,它给出了mi错误:

Supplied parameters do not match any signature of call target. 提供的参数与呼叫目标的任何签名都不匹配。

It's because it generates ngfactory file with wrong number of parameters for AnimationOutput : 这是因为它为AnimationOutput生成了错误的参数数量的ngfactory文件:

this.registerAnimationOutput(
    this._el_0,
    new import24.AnimationOutput('fadeInOut','done'), <-- should be 3 args
    this.eventHandler(this._handle__fadeInOut_done_0_1.bind(this))
);

If I remove done callback from the template, compilation works. 如果我从模板中删除完成回调,编译工作。

I'm using Angular 2 RC.6 我正在使用Angular 2 RC.6

Update: It is working on angular "2.0.2" 更新:正在开发角度“2.0.2”

I am having the same issue, looks there is internal bug in angular animations or AOT compiler. 我有同样的问题,看起来有角动画或AOT编译器的内部错误。

You can track progress here: https://github.com/angular/angular/issues/11707 您可以在此处跟踪进度: https//github.com/angular/angular/issues/11707

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM