title: Handling 'back' button in nativescript angular2 inside component
body: <p>I'm trying to handle 'back' button as shown in <a href="https://stackoverflow.com/questions/40603588/nativescript-handling-back-button-event">Nativescript handling back button</a>. There are two methods proposed, and both run ok. My problem is how to interact with my component's local data, since 'android.on' is a global event.</p>
  
  <p>What I want to do is to refresh the display (just by updating the model of a list referenced in an ngFor) when my components receives control again from another display (which the users closes by tapping 'back' button).</p>
  
  <p>I've been trying to access 'activityBackPressedEvent' properties, but I can't find a way to access component data ('shopList').</p>
  
  <pre><code>import { Component, OnInit, ViewChild } from "@angular/core";
  import { Router } from "@angular/router";
  import { RouterExtensions } from "nativescript-angular/router";
  import { Page } from "ui/page";
  import { ObservableArray } from "tns-core-modules/data/observable-array";
  import { TokenModel } from "nativescript-ui-autocomplete";
  import { RadAutoCompleteTextViewComponent } from "nativescript-ui-autocomplete/angular";
  import { Utils } from '../../utils';
  import * as SocialShare from "nativescript-social-share";
  import { android, AndroidApplication, AndroidActivityBackPressedEventData } from "application";
  import * as application from "tns-core-modules/application";
  import {topmost} from "ui/frame";
  
  @Component({
      //selector: "Shopping",
      moduleId: module.id,
      templateUrl: "./shopping.component.html",
      styleUrls: ['./shopping.component.css']
  })
  
  export class ShoppingComponent implements OnInit {
      shopList: string[] = [];
      constructor(private page: Page, private router: Router, private routerExt: RouterExtensions) {
          this.shopList = [];
          this.shopList.push ('sugar');
          this.shopList.push ('milk');
      }
  
      reload(args: AndroidActivityBackPressedEventData): void {
          console.log ('back pressed');
          console.log (this.shopList);  // &lt;&lt;--- "undefined"
      }
  
      ngOnInit(): void {
          android.on(AndroidApplication.activityBackPressedEvent, this.reload);
      }
  }
  </code></pre>