OnsenUI/OnsenUI — pull request #74 by marqu3z (2014-03-28 16:38:32+00:00)
Title: Useful API methods for ons.navigator

I think the `ons.navigator` should have more features.
Hope those could be useful to improve the framework.

* **Pass and retrieve parameters between pages** (issue #65)
* **Know which is the current page** (issue #68)
* **Retrieve the entire page stack** (In my case to know if the back button on the device should go back on the stack or close the app if there are no pages to pop.

All those methods are exposed on the `ons.navigator` object or in the `NavigatorStack` service.
```
// Pass parameters to another page
ons.navigator.pushPage("path/to/page.html", {foo: "bar"})

// Retrieve parameters from the other page
ons.navigator.getCurrentPage().options.foo // "bar"

// Retrieve the current page
ons.navigator.getCurrentPage().options.page // "path/to/page.html"

// Retrieve the entire stack
ons.navigator.getPages() // [pageObj1, pageObg2, ... , pageObj3]

// Example of using the stack to change the behavior of the back button
document.addEventListener("backbutton", function (e) {
if ($rootScope.ons.navigator.getPages().length > 1) {
e.preventDefault();
$rootScope.ons.navigator.popPage();
}
else
navigator.app.exitApp();
}, false);
```