title: Angular - recalculate a variable on every change
body: <p>I have a variable that stores the available cars at any moment. Is there a way to automatically re-evaluate this function on every change?</p>
  
  <p>Just using this.carFactory.available in this case is not a solution, because this example I'm showing is simplified - the real calculation in my project is alot more complex.</p>
  
  <pre><code>calculateAvailableCars(){
      this.carFactory.available.forEach(function(item){
        this.availableCars.push(car.id);
      }.bind(this));
  }
  </code></pre>
  
  <p>How could I do this in Angular 2? In Angular JS there was the possibility to $watch a function.</p>
  
  <p>I could of course manually call this function everytime something changes, but it would be nice not to have to call this function in every part of the application that can change the data.</p>