angular2 universal 앱을 쓰고 있습니다. 그것은 d3 차트를 가지고 있지만 클라이언트 측 (브라우저)에서 d3 차트 만 렌더링하고 서버에서 렌더링하지는 않기를 바랬습니다. 컴포넌트가 클라이언트 쪽에서 만 실행되는 angular2 universal 인터페이스가 있습니까? 즉Angular2 Universal을 사용하는 클라이언트에서만 구성 요소 메소드를 실행할 수 있습니까?
class ComponentWithChart implements OnInit, ngUniversalBrowser {
elem;
constructor(private viewContainerRef:ViewContainerRef) {}
ngUniversalBrowserOnInit() {
this.elem = this.viewContainerRef.element.nativeElement;
d3.select(this.elem).append('div').style({
'background-color':'yellow'
});
}
}
이 날은 브라우저 만 OnInit
에 ngUniversalBrowser
방법을 실행하도록 허용 할 수 있습니다 그 위의 예와 같이 있나요?