title: How to reasign object with `this` in Angular component?
body: <p>I have 2 variables inside an Angular component/class <code>FilterComponent</code> that point to an object. The first one (<code>localStorage</code>) stores the results of the current filtering choices that the user makes and is connected with toogle buttons with <code>[(ngValue)]</code>. The second one (<code>globalStorage</code>) gets the results of filtering choices that the user made earlier within other components (if you for example click on <code>fruit</code> on home page,globalStorage.food gets updated, but not the <code>localStorage</code> within <code>FilterComponent</code>). I have a method that should assign gloablStorage to localStorage when the user open the filter that looks like this:</p>
  
  <pre><code>openFilter() {
    this.localStorage = this.globalStorage; //this line is responsible for strange behaviour
    ...
  }
  </code></pre>
  
  <p>This works exactly like it should, but only after the <code>apply</code> button on filter (within FilterComponent) is clicked, which is responsible for sending the contents of localStorage to globalStorage (via next/behaviourSubject).</p>
  
  <p>For some mysterious reason, before that happens, the values of toggleButtons get assign to globalStorage as well as to localStorage (although they are connected only to localStorage). Why is this happening and how can I fix it?</p>