title: access the values every where in multiple components in Angular 2?
body: <p>i have to use the user object coming from db in every component , for that i have choose ionic-storage to store user and even i can access any where in my component. but i got an issue when using ngOnChanges() in my component. the ngOnChanges is triggered before my constructor got initialized, in my constructor i have a logic to get the user from localStorage.</p>
  
  <p>in ngOnChanges() method i checking if user exits assigning some value. my condition fails every time because getting user logic is defined in constructor.</p>
  
  <h2>   child Component</h2>
  
  <pre><code>     @Component({
        selector: 'my-fav-icon',
        templateUrl:``&lt;ion-icon name="ios-heart-outline"  *ngIf="IsLike" (click)="onAddToFavorite()"&gt;&lt;/ion-icon&gt;
  &lt;ion-icon name="ios-heart" *ngIf="!IsLike" (click)="onAddToFavorite()"&gt;&lt;/ion-icon&gt;
  `,
         })
           import { Component,Input,OnChanges,DoCheck} from '@angular/core';
              import { Storage } from '@ionic/storage';
  
              export class ChildComponent implements OnChanges {
               constructor(public storage:Storage) {
               this.storage.get('authentication').then((userResp) =&gt; {
                 this.user = userResp
                  console.log('category-video.ts --&gt;Name has been set'+JSON.stringify(userResp));   //printed second
                });
  
                }
  
  
            IsLike:String
              @Input() 
              singleItem : any;
  
              ngOnChanges(changes){
                  console.log('on-ng-changes is called');//printed first
                  if(this.user){ 
                    if(this.user.favorites.indexOf(changes.currentValue.videoId) == -1){
                        this.IsLike =true;  
                      }else{
                      this.IsLike =false;
                      }
                  }else{
                      this.IsLike =true;
                  }
  
  
          }
  
              }  
  </code></pre>
  
  <h2>parent component</h2>
  
  <pre><code> @Component({
    selector: 'page-categories',
    templateUrl: 'categories.html',
  })
   export class ParentComponent{
  
  }
  </code></pre>
  
  <h2>categories.html</h2>
  
  <pre><code>&lt;div *ngFor="let item of cats"&gt;
  &lt;h1&gt;My parent class component&lt;/h1&gt;
  &lt;ion-col text-right&gt;
    &lt;my-favorite-icon [singleItem]="item" &gt;&lt;/my-favorite-icon&gt;
   &lt;/ion-col&gt;
  &lt;/div&gt;
  </code></pre>