title: Angular 6 'data' become Undefined when refreshing the page
body: <p>I am using angular 6 to develop a new web app.I am sending data from one component to another using a 'sharedservice'.I can send it very comfortably.
  When i try to refresh the page the shared service data become undefined and app breaks. Of course i am tried with an if condition and it works perfectly,and app redirected to previous page;</p>
  
  <p>But is there any other way rather than if condition,so the browser should stay in 'setupItemComponent' with previous data and shared data should not be an undefined one</p>
  
  <p>Thanks in advance</p>
  
  <p>here is my code:</p>
  
  <pre><code>setup.ts:
  =================
  
  constructor(private router:Router,private sharedservice:SharedService){}
  
  onCLickEdit(clickedData:any){
  
  //function will execute when button clicks
  sharedservice.data=clickedData;
  this.router.navigate(['setup/setup_items'])
  }
  
  
  setupItem.ts
  ====================
  
  data:any;
  constructor(private sharedservice:sharedService){}
  
  ngOnInit() {
  this.data = this.sharedData.data;
  if (this.data) {
    this.formValidation();
  }
  else {
    this.router.navigate(['setup']);
  }
  
  }
  
  
   sharedService.ts
  ==================
  
  import { Injectable } from '@angular/core';
  
  @Injectable({
  providedIn: 'root'
   })
   export class ShareDataService {
  
  data: any;
  
  constructor() { }
  
  
  }
  </code></pre>