title: how do make hardware back button become exit app
body: <p>I found this code but its for javascript:</p>
  
  <pre><code>document.addEventListener("deviceready", onDeviceReady, false);
  
  function onDeviceReady(){
      document.addEventListener("backbutton", function(e){
         if($.mobile.activePage.is('#homepage')){
             e.preventDefault();
             navigator.app.exitApp();
         }
         else {
             navigator.app.backHistory()
         }
      }, false);
  }
  </code></pre>
  
  <p>this case is like my case, that I want to make the back button become the exit way of my app when in certain page (in this case is /home) but this code is written in javascript, I want to make this in angularjs, how do I write it? thanks</p>