back button implementation nativescript angular code example

Example: nativescript angular back button event

import { Frame } from 'tns-core-modules/ui/frame';...private _backButton() {  const currentView = Frame.topmost().currentPage;    application.android.on(application.AndroidApplication.activityBackPressedEvent, (args: application.AndroidActivityBackPressedEventData) => {        if (currentView.hasListeners('BackButton')) {          args.cancel = true;          currentView.notify({            eventName: 'BackButton',            object: currentView          });        } else          args.cancel = false;             });  }