我创建了自己的指令,如果用户未登录则会隐藏内容:* onlyUser。当我尝试在使用ng / animation的组件中使用它时,我有时会收到错误:
Cannot read property 'insertNode' of undefined at TransitionAnimationEngine
指令如下所示:
export class OnlyUserDirective {
constructor(private _templateRef: TemplateRef<any>,
private _viewContainer: ViewContainerRef,
private _userContextService: UserContextService) {
this._userContextService.isLogged$().subscribe(x => {
if (x === true) {
this._viewContainer.createEmbeddedView(this._templateRef);
} else {
this._viewContainer.clear();
}
});
}
}
当我尝试在带有@Component({animations:[...]}的组件中使用它时,我有时会从这个问题的开头得到错误。这是预期的行为,还是一个有角度的错误?
答案 0 :(得分:0)
这是一个已知的错误 - &gt; https://github.com/angular/angular/issues/19712。 我正在检查它是否与Angular 5一起使用