title: "this" becomes undefined in ngOnInit
body: <p>"this" becomes undefined in ngOnInit</p>
  
  <p>I am trying to push the object that is returned on a callback into a globally defined array. </p>
  
  <p>but it gives error that </p>
  
  <p>"cannot read property of undefined"</p>
  
  <pre><code>export class ItemsComponent implements OnInit {
  items: Item[];
  devices: any[];
  constructor(private itemService: ItemService) {
      this.devices = new Array();
  }
  ngOnInit(): void {
      bluetooth.isBluetoothEnabled().then(
          enabled =&gt; console.log("Enabled ? " + enabled)
      );
      bluetooth.startScanning({
          serviceUUIDs: [],
          seconds: 4,
          onDiscovered: function(peripheral) {
              this.devices.push(peripheral);
          }
      }).then(function() {
          console.log("scanning complete");
      }, function(err) {
          console.log("error while scanning: " + err);
      });
      this.items = this.itemService.getItems();
  }}
  </code></pre>
  
  <p>i get this error at</p>
  
  <pre><code>this.devices.push(peripheral);
  </code></pre>