Constructor of class 'HubConnection' is private and only accessible within the class...

Discussão em 'Angular' iniciado por Ibanez1408, Junho 21, 2025.

  1. Ibanez1408

    Ibanez1408 Guest

    I am trying to implement an Angular and Signalr project. I am getting the sample from Medium

    I have installed all the necessary packages and have the code below in the app.component.ts:

    import { Component, OnInit } from '@angular/core';
    import { HubConnection } from '@aspnet/signalr';

    import { Message } from 'primeng/api';

    @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
    })
    export class AppComponent {
    title = 'PROJECT TITLE';
    base_url = 'http://localhost:8081/';

    hubConnecton: HubConnection;
    msgs: Message[] = [];

    constructor() {

    }

    ngOnInit(): void {
    this.hubConnecton = new HubConnection(this.base_url);
    }
    }


    But I get an error in the = new HubConnection(this.base_url); with this message: Constructor of class 'HubConnection' is private and only accessible within the class declaration.

    [​IMG]

    Continue reading...

Compartilhe esta Página