Javascript 角度:无法读取属性';插入节点';在TransitionAnimationEngine中未定义的
我创建了自己的指令,如果用户未登录,该指令将隐藏内容:*onlyUser。当我尝试在使用ng/动画的组件中使用它时,有时会出现错误:Javascript 角度:无法读取属性';插入节点';在TransitionAnimationEngine中未定义的,javascript,angular,Javascript,Angular,我创建了自己的指令,如果用户未登录,该指令将隐藏内容:*onlyUser。当我尝试在使用ng/动画的组件中使用它时,有时会出现错误: Cannot read property 'insertNode' of undefined at TransitionAnimationEngine 指令如下所示: export class OnlyUserDirective { constructor(private _templateRef: TemplateRef<any>,
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();
}
});
}
}
export class OnlyUserDirective{
构造函数(私有的_templateRef:templateRef,
private _viewContainer:ViewContainerRef,
private_userContextService:userContextService){
此._userContextService.isLogged$().subscribe(x=>{
如果(x==true){
this.\u viewContainer.createEmbeddedView(this.\u templateRef);
}否则{
此._viewContainer.clear();
}
});
}
}
当我试图在带有@component({animations:[…]})的组件中使用它时,我有时会从这个问题的开头得到错误。这是预期的行为,还是一个角度错误?这是一个已知的错误->。
我正在检查它是否在处理Angular 5类似的问题