title: Angular, data loss when page refresh
body: <p>I have a little question in Angular.</p>
  <p>I have a button in a component that when pressed, selects a game and runs a function and that function just sends the game to a service called <strong>SelectedGameService</strong>, so that I can understand which game was selected. Here are my codes;</p>
  <p>The button in <strong>games.component.html</strong>;</p>
  <pre><code>&lt;a class=&quot;btn btn-primary&quot; (click)=&quot;handleDetails(game)&quot; style=&quot;position: absolute; top:86%; background-color: #0909CD;&quot; routerLink=&quot;/games/game-details/{{game.title}}&quot;&gt;See The Game Details&lt;/a&gt;
  </code></pre>
  <p>As I have said, the handleDetails(game) function sends the game to that function. That handleDetails function in game.component.ts is;</p>
  <pre><code>handlePrice(game) {
      this.selectedGameService.selectedGame = game;
    }
  </code></pre>
  <p>That function send the game to selectedGameService. here are my codes in that service;</p>
  <pre><code>import { Injectable } from '@angular/core';
  import { Games } from '../games/Games';
  import { Observable } from 'rxjs';
  import { HttpClient } from '@angular/common/http'; 
  
  @Injectable({
    providedIn: 'root'
  })
  export class SelectedGameService {
  
    selectedGame: Games;
    constructor(private http: HttpClient) { 
      this.selectedGame = new Games;
    }
  </code></pre>
  <p>So basically this service creates a new game and equals it to the game that triggered the <strong>handlePrice(game)</strong> function.</p>
  <p>Here is my problem. When I run the code, it runs perfectly in browser. When I press &quot;See The Game Details&quot; button I can see the page as I want, but when I refresh the browser while at that page, all the information of the game disappears. How can I solve  this problem?</p>
  <p>You can see the before and after pictures of when I refresh the browser while at that page.</p>
  <p>Thank you from now.</p>
  <p><a href="https://i.stack.imgur.com/02T9f.png" rel="nofollow noreferrer">Before Refreshing The Page</a></p>
  <p><a href="https://i.stack.imgur.com/wEtHN.png" rel="nofollow noreferrer">After Refreshing The Page</a></p>