title: Connect Angular 2 with sails.js
body: <p>I'm trying to connect my Angular 2 with sails using <a href="https://github.com/joeherold/angular2-sails" rel="nofollow noreferrer">angular2-sails</a> using the following line:</p>
  
  <pre><code>this.sailor = this._sailsService.connect("http://localhost:1337");
  </code></pre>
  
  <p>I did import sails.io.js in my angular 2 appplication index.html:</p>
  
  <pre><code>&lt;script src="/assets/scripts/sails.io.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Added SailsModule in my app.module.ts:</p>
  
  <pre><code>    import {SailsModule} from "angular2-sails";
  ..
      SailsModule.forRoot(
  </code></pre>
  
  <p>And in my component:</p>
  
  <pre><code>import {SailsService} from "angular2-sails";
  ...
  constructor(private _sailsService:SailsService) {
  }
  
  ngOnInit() {
      this._sailsService.connect("http://localhost:1337");
    }
  </code></pre>
  
  <p>but the browser return errors:</p>
  
  <pre><code>Failed to load resource: the server responded with a status of 404 (Not Found)
      polyfills.js:3 GET http://localhost:8100/socket.io/?__sails_io_sdk_version=0.13.8&amp;__sails_io_s…owser&amp;__sails_io_sdk_language=javascript&amp;EIO=3&amp;transport=polling&amp;t=LluuhLV 404 (Not Found)
      e @ polyfills.js:3
      t.scheduleTask @ polyfills.js:3
      n.scheduleTask @ polyfills.js:3
      n.scheduleMacroTask @ polyfills.js:3
      (anonymous) @ polyfills.js:3
      send @ VM944:3
      f.create @ sails.io.js:14
      f @ sails.io.js:14
      e.request @ sails.io.js:14
      e.doPoll @ sails.io.js:14
      d.poll @ sails.io.js:14
      d.doOpen @ sails.io.js:14
      d.open @ sails.io.js:14
      d.open @ sails.io.js:14
      d @ sails.io.js:14
      d @ sails.io.js:14
      d.open.d.connect @ sails.io.js:15
      d @ sails.io.js:15
      d @ sails.io.js:15
      d @ sails.io.js:15
      goAheadAndActuallyConnect @ sails.io.js:853
      selfInvoking @ sails.io.js:830
      SailsIOClient.SailsSocket._connect @ sails.io.js:849
      (anonymous) @ sails.io.js:1481
      sails.service.js:172 Client has connected to the server!
      sails.io.js:438 
  
        |&gt;    Now connected to Sails.
      \___/   For help, see: 
              (using sails.io.js browser SDK @v0.13.8)
  
  
  
      sails.io.js:438  
              Socket is trying to reconnect to Sails...
      _-|&gt;_-  (attempt #1)
  </code></pre>
  
  <p>Not sure if there is anything to do with it, but I'm using Ionic 2 (cordova)
  What's wrong? </p>