|
1 | | -import { Directive, ElementRef, OnInit } from '@angular/core'; |
| 1 | +import { afterNextRender,Directive, ElementRef, inject } from '@angular/core'; |
2 | 2 | import { Viewer } from 'cesium'; |
3 | 3 |
|
4 | 4 | @Directive({ |
5 | | - selector: '[appCesium]', |
6 | | - standalone: true |
| 5 | + selector: '[appCesium]' |
7 | 6 | }) |
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)); |
14 | 11 | } |
15 | | - |
16 | 12 | } |
0 commit comments