bougarfaoui / ng-socket-io

Socket.IO module for Angular
MIT License
254 stars 57 forks source link

Can't resolve all parameters for Myservice #34

Open eduardoBenn opened 6 years ago

eduardoBenn commented 6 years ago

When I use multiple sockets, I receive this error message: Can't resolve all parameters for MyService: ([object Object], ?).

This is my app.module `...

import {Socket, SocketIoModule} from 'ng-socket-io';

@Injectable() export class SocketOne extends Socket {

constructor() { super({ url: 'http://url_one:portOne', options: {} }); } } @NgModule({ declarations: [...], imports: [ BrowserModule, SocketIoModule ... ], providers: [ .. SocketOne ]`

And this is my service: ` ...

import {SocketOne} from '../app.module';

@Injectable()

export class MyService {

constructor( private socket: SocketOne ){

  this.socket.connect()   

}   

}`

What could be happening?

bougarfaoui commented 6 years ago

which version you're using ?

TheLLspectre commented 6 years ago

Yeah i've the same issue

Error: Can't resolve all parameters for SocketRasp: (?).

i have an object/page called home, which allow me to show html in my viewer, and create a Socket, which i want to be linked to this homePage, and i can called a lot of HomePage, to have something like 8 pages with Socket

`import { Injectable, NgModule, Inject, Component } from '@angular/core'; import { NavController } from 'ionic-angular'; import { HttpClient } from '@angular/common/http'; //import { Socket } from 'ng-socket-io'; import { SocketRasp } from '../../assets/typescript/SocketRasp' import 'rxjs/add/operator/map'; @Component({ selector: 'page-rasp', templateUrl: 'home.html', }) export class HomePage /extends Socket/ {

private ipAddress: String;
private ip: String;
//private rasp: SocketRasp;

constructor(private rasp: SocketRasp)
{
    /*this.ip = ip;
    this.ipAddress = this.ip;
    this.setRasp(new SocketRasp(this.ipAddress));
    console.log(this.rasp);*/
}

//getters

public getIpAddress()
{
    return this.ipAddress;
}

public getRasp()
{
    return this.rasp;
}

public getIp()
{
    return this.ip;
}

//setters

public setIpAddress(ipAddress: String)
{
    this.ipAddress = ipAddress;
}

public setRasp(rasp: SocketRasp)
{
    this.rasp = rasp;
}

public setIp(ip: String)
{
    this.ip = ip;
}

//methods

}`

and then i have the socketRasp:

import { NgModule } from '@angular/core'; import { Socket } from 'ng-socket-io'; export class SocketRasp extends Socket { constructor(private ipAddress: String) { super({ url: 'http://' + ipAddress + ':8080', options: {} }); //Port can be placed in ipAddress, think to delete it, in that case } //getters //setters //methods }

So in first time i've this error. And i would like to work without the provider and enter the Ip of each socket by myself

how we can fix this problem of parameter ? May be with ngx-sochet-io ?