I am importing a class to another class and I want to access its non-static property in Angular but I am unable to do that.
Here is the code that I am using:
Websocket.config.ts
export class WebSocketConfig implements OnInit{
auth$: Subscription;
userInfo: UserInfo;
user_name: string;
username: string;
constructor(private authService: AuthorizationService){
}
ngOnInit() {
this.username = this.getUserName();
}
getUserName(): string{
this.auth$ = this.authService.getUserInformation().subscribe(result => {
this.userInfo = result;
this.user_name = this.userInfo.user_id;
});
return this.user_name;
}
public static uri: string = "wss://localhost:9093/powerme-notification-websocket/websocket";
public static notification_topic : string = '/user/topic/releaseLock';
}
shared.module.ts
const stompConfig : StompConfig = {
url : WebSocketConfig.uri,
headers: {client_id: WebSocketConfig.username},
heartbeat_in: 0,
heartbeat_out: 20000,
reconnect_delay: 5000,
debug: false
}
In the WebSocketConfig.username, It says that "Property username does not exist on type "typeOf WebSocketConfig".
I am using Stomp and websocket for sending notifications.