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

时间:2016-09-06 09:57:55

标签: javascript angular compiler-errors

我的组件定义如下:

@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 {...}
    ...
}

模板看起来像这样:

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

应用程序在使用JIT编译时工作正常,完成回调被正确触发,但是当我尝试使用ngc(v.6.0.0)编译它时,它给出了mi错误:

提供的参数与呼叫目标的任何签名都不匹配。

这是因为它为 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))
);

如果我从模板中删除完成回调,则编译可以正常工作。

我正在使用Angular 2 RC.6

1 个答案:

答案 0 :(得分:0)

更新:正在处理角度“2.0.2”

我遇到了同样的问题,看起来在角度动画或AOT编译器中存在内部错误。

您可以在此处跟踪进度:https://github.com/angular/angular/issues/11707

相关问题