The default deviceButton behavior for dialog
is hiding. In order to change it you can do it in this way:
ons.bootstrap().controller('MyController', function($scope) {
$scope.hideDialog = true;
$scope.changeMode = function() {
$scope.hideDialog = !$scope.hideDialog;
if ($scope.hideDialog) {
console.log('now hiding');
$scope.dialog.getDeviceBackButtonHandler().setListener(function() { $scope.dialog.hide();});
} else {
console.log('now printing');
$scope.dialog.getDeviceBackButtonHandler().setListener(function() { console.log('hey!');});
}
};
ons.ready(function() {
ons.createDialog('dialog.html').then(function(dialog) {});
});
});
And this is the example HTML:
<body ng-controller="MyController">
<ons-template id="dialog.html">
<ons-dialog var="dialog" cancelable>
<p>Mode: {{ hideDialog ? "Hide Dialog" : "ConsoleLog Hey" }}</p>
<p><ons-button ng-click="changeMode()">Change Mode</ons-button></p>
</ons-dialog>
</ons-template>
<ons-page>
<p><ons-button ng-click="dialog.show()">Show Dialog</ons-button></p>
</ons-page>
</body>
I just tested that in Onsen UI 1.3.8 and Monaca, seems working well.
Hope it helps!