title: test if service exists
body: <p>I'm opening a connection of my database in my ionic application. I want that this connection can be used in all tabs. For that I do a service and try save in them the connection variable.</p>
  
  <pre><code>.service('connect', function () {
              var arr = {};
              var connection = new ...
              arr['connection'] = connection;
              }
              return arr;
          })
  </code></pre>
  
  <p>Then, to access to them, I do: </p>
  
  <pre><code>connect.connection;
  </code></pre>
  
  <p>Problem: I want to do a new connection just the first time I do a connect.connection. The other ones I want just to get back the variable.</p>
  
  <p>I tried anything like that:</p>
  
  <pre><code>if(connect == null){
              var connection = new ...
              arr['connection'] = connection;
  }
  </code></pre>
  
  <p>inside my service, but it cannot work.</p>
  
  <p>Do you have an idea?</p>