title: NativeScript handling back button event
body: <p>I am trying to handle the hardware back button in a NativeScript app. I am using NativeScript version 2.3.0 with Angular.</p>
  
  <p>Here is what I have in <code>main.ts</code> file</p>
  
  <pre><code>// this import should be first in order to load some required settings (like globals and reflect-metadata)
  import { platformNativeScriptDynamic, NativeScriptModule } from "nativescript-angular/platform";
  import { NgModule,Component,enableProdMode } from "@angular/core";
  import { AppComponent } from "./app.component";
  import { NativeScriptRouterModule } from "nativescript-angular/router";
  import { routes, navigatableComponents } from "./app.routing";
  import { secondComponent } from "./second.component";
  import {AndroidApplication} from "application";
  @Component({
      selector: 'page-navigation-test',
      template: `&lt;page-router-outlet&gt;&lt;/page-router-outlet&gt;`
  })
  export class PageNavigationApp {
  }
  @NgModule({
      declarations: [AppComponent,PageNavigationApp,secondComponent
          // ...navigatableComponents
          ],
      bootstrap: [PageNavigationApp],
      providers:[AndroidApplication],
      imports: [NativeScriptModule,
          NativeScriptRouterModule,
      NativeScriptRouterModule.forRoot(routes)
      ],
  })
  class AppComponentModule {
  
      constructor(private androidapplication:AndroidApplication){
          this.androidapplication.on("activityBackPressed",()=&gt;{
              console.log("back pressed");
  
          })
      }
  
  }
  
  enableProdMode();
  
  platformNativeScriptDynamic().bootstrapModule(AppComponentModule);
  </code></pre>
  
  <p>I am importing application with </p>
  
  <p><code>import {AndroidApplication} from "application";</code></p>
  
  <p>Then in the constrouctor of <code>appComponentModule</code> I am registering the event for <code>activityBackPressed</code> and just doing a console.log.</p>
  
  <p>This does not work.</p>
  
  <p>What am I missing here?</p>