Getting ERR_CONNECTION_REFUSED in chrome and Firefox?

时间:2017-12-18 06:41:27

标签: angular typescript

I'm developing Angular2 website. It is working fine in IE but I'm getting ERR_CONNECTION_REFUSED error in Chrome and Firefox.

Below is My Code:

Below is my home.component.html:

<div class="log_wrap">
          <div class="log_img"></div>
          <ul class="log_list">
            <li>USER ID<br>
                <input class="log_input" placeholder="Login ID" id="LoginID" type="text">
            </li>
            <li>PASSWORD<br>
                <input class="log_input" placeholder="*******" id="password" type="password">
            </li>

            <li>
              <input type="button" class="reset_but" value="Reset"/>
                <input type="button" class="log_but" value="Login" (click)="login_btnClick()"/>
            </li>
          </ul>
        </div>

Below is my home.component.ts:

export class HomeComponent {
    homes: IHome[];
    home: IHome;
    msg: string;
    indLoading: boolean = false;
    constructor(private fb: FormBuilder, private _homeService: HomeService, private router: Router) { }

    login_btnClick() {
        var Domain = "sgl";
        var Username = ((document.getElementById("LoginID") as HTMLInputElement).value);
        var Password = ((document.getElementById("password") as HTMLInputElement).value);
        this._homeService.get(Global.BASE_USER_ENDPOINT + '/ValidateEmployee?Domain=' + Domain + '&Username=' + Username + '&Password=' + Password)
            .do(data => sessionStorage.setItem('session', Username))
            .subscribe(homes => {
                this.homes = homes;
                this.indLoading = false;
                var NT = sessionStorage.getItem('session');
                //this.router.navigateByUrl('/user');
                this.EmpDetails();
            },
            error => this.msg = <any>error);
    }
}

Below is my home.ts:

export interface IHome {
    EmpName: string,
    EmpNumber: string,
    EmailId: string,
    Id: number,
    FirstName: string,
    LastName: string,
    Gender: string
}

And below is my home.service.ts:

export class HomeService {
    constructor(private _http: Http) { }
    get(url: string): Observable<any> {
        return this._http.get(url)
            .map((response: Response) => <any>response.json())
            //.do(data => console.log("All: " + JSON.stringify(data)))
            .catch(this.handleError);
    }

this code is working perfectly in IE and its not working in Google Chrome and Firefox.I'm getting ERR_CONNECTION_REFUSED error.

Here is my angular-cli.json: angular-cli.json

 {
      "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
      "project": {
        "name": "i-roz-ui"
      },
      "apps": [
        {
          "root": "src",
          "outDir": "dist",
          "assets": [
            "assets",
            "favicon.ico"
          ],
          "index": "index.html",
          "main": "main.ts",
          "polyfills": "polyfills.ts",
          "test": "test.ts",
          "tsconfig": "tsconfig.app.json",
          "testTsconfig": "tsconfig.spec.json",
          "prefix": "app",
          "styles": [
            "styles.css"
          ],
          "scripts": [],
          "environmentSource": "environments/environment.ts",
          "environments": {
            "dev": "environments/environment.ts",
            "prod": "environments/environment.prod.ts"
          }
        }
      ],
      "e2e": {
        "protractor": {
          "config": "./protractor.conf.js"
        }
      },
      "lint": [
        {
          "project": "src/tsconfig.app.json",
          "exclude": "**/node_modules/**"
        },
        {
          "project": "src/tsconfig.spec.json",
          "exclude": "**/node_modules/**"
        },
        {
          "project": "e2e/tsconfig.e2e.json",
          "exclude": "**/node_modules/**"
        }
      ],
      "test": {
        "karma": {
          "config": "./karma.conf.js"
        }
      },
      "defaults": {
        "styleExt": "css",
        "class": {
          "spec": false
        },
        "component": {
          "spec": false
        },
        "directive": {
          "spec": false
        },
        "guard": {
          "spec": false
        },
        "module": {
          "spec": false
        },
        "pipe": {
          "spec": false
        },
        "service": {
          "spec": false
        }
      }
    }

1 个答案:

答案 0 :(得分:0)

Please try to run chrome with parameter: --disable-web-security