-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathballoon.class.ts
More file actions
21 lines (18 loc) · 861 Bytes
/
Copy pathballoon.class.ts
File metadata and controls
21 lines (18 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { isPlatformBrowser } from '@angular/common';
import { Inject, PLATFORM_ID } from '@angular/core';
import { IBalloon } from "./balloon.interface";
const colors = ['red', 'blue', 'purple', 'orange'];
export class Balloon implements IBalloon {
id: string;
color: string;
constructor(@Inject(PLATFORM_ID) private platformId: Object) {
if (isPlatformBrowser(this.platformId)) {
this.id = window.crypto.randomUUID();
this.color = colors[Math.floor(Math.random() * colors.length)];
} else {
// Provide a fallback or handle the case where 'window' is not available
this.id = 'default-id'; // You can change this to some other logic if necessary
this.color = 'default-color'; // You can change this to some other logic if necessary
}
}
}