title: Angular2 Sharing variable or Global variable between pages/Components
body: <p>I'm trying to create Cart functionality in my MOBILE POC (Cordova2/Angular2).
  I've created Service for share data between components. I'adding items through Component A and trying to read from Component B. But I'm not seeing those items in Component B. What should I add in Service?</p>
  
  <pre><code>import { Injectable  } from '@angular/core';    
  @Injectable()    
  export class CartService {
      private vijayCart: Array&lt;any&gt; = [];
      GetCart() {
          return this.vijayCart;
      }
      SetCart(item) {
          this.vijayCart.push(item);
      }
  }  
  </code></pre>
  
  <p>Component A:</p>
  
  <pre><code>addItemToCart(item) {
      this.cartService.SetCart(item);
      //this.cartService.vijayCart.push(item);
      this.cartLenth = this.cartService.GetCart().length;
  }
  </code></pre>
  
  <p>Component B:</p>
  
  <pre><code>  ngOnInit(): void {
        this.cartSer = this.cartService.GetCart();
    }
  </code></pre>