Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 55c5817

Browse files
committed
Use afterNextRender to create the viewer
1 parent e2ad1db commit 55c5817

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

‎src/app/cesium.ts‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import { Directive, ElementRef, OnInit } from '@angular/core';
1+
import { afterNextRender,Directive, ElementRef, inject } from '@angular/core';
22
import { Viewer } from 'cesium';
33

44
@Directive({
5-
selector: '[appCesium]',
6-
standalone: true
5+
selector: '[appCesium]'
76
})
8-
export class Cesium implements OnInit {
9-
10-
constructor(private el: ElementRef) {}
11-
12-
ngOnInit(): void {
13-
const viewer = new Viewer(this.el.nativeElement);
7+
export class Cesium {
8+
constructor() {
9+
const el = inject(ElementRef);
10+
afterNextRender(() => new Viewer(el.nativeElement));
1411
}
15-
1612
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /