title: Create or increment a value with Angular2/AngularFire2
body: <p>I'm using Angular 2 and AngularFire 2 to interact with Firebase.  In Firebase I have a tags collection.  I'd like to either create or increment the number for a tag.  The code I'm using looks something like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>let tagName = "angular";
  let tagObs = this.af.database.object(`/tags/${tagName}`);
  tagObs.subscribe(function(snapshot) {
      let newValue = (snapshot.$value) ? (snapshot.$value + 1) : 1;
      this.tagObs.set(newValue);
  }.bind({ tagObs: tagObs ));
  </code></pre>
  
  <p>It's not clear to me why, but this doesn't work.  It creates an infinite loop that just keeps incrementing the tag value.</p>
  
  <p>Using AngularFire 2, how should I go about either creating or incrementing a value for a node (a "tag" in this case)?</p>
  
  <h2>Update after @Fiddle's comment</h2>
  
  <p>Here is the same code with a "fat arrow" function.  The same problem exists... an infinite loop.</p>
  
  <pre class="lang-js prettyprint-override"><code>let tagName = "angular";
  let tagObs = this.af.database.object(`/tags/${tagName}`);
  tagObs.subscribe((snapshot) =&gt; {
      let newValue = (snapshot.$value) ? (snapshot.$value + 1) : 1;
      tagObs.set(newValue);
  });
  </code></pre>
  
  <h2>Update # 2: the code that worked</h2>
  
  <p>Just for the sake of clarity, this is the actual code I ended up using:</p>
  
  <pre class="lang-js prettyprint-override"><code>let tagObs = this.af.database.object(`/tags/${tagName}`);
  tagObs.transaction(function(currentCount) {
    return currentCount + 1;
  });
  </code></pre>