目前在我的Web應用程序中,我正在執行如下面的代碼所示。 因此,在達到$ window後,會發生什麼情況.Confirm編譯器會等待警報框的響應,並取決於請假得到true或false。 最後,此方法將該布爾值返回至其耦合方法。如何使用HYBRID mobileApp(iOS)中的notification.confirm替換window.confirm
// **的Web APP ** //
function shouldLeave(next)
var message = 'Do you wish to leave this Page';
var leave = $window.confirm(message); // Return bool value as per user selection
if (leave) {
//Doing my job...
reset();
}
return leave;
}
現在雜交我在做什麼是:
function shouldLeave(next) {
var message = 'Do you wish to leave this Page';
var leave = notification.confirm(message, callbackMethod(),title,[Ok, Cancel]); // Here there is no return value . Return depends on Callback as the callback method gets called depending on user selection
if (leave) {
//Doing my job...
reset();
}
return leave;
}
function CallBack(index)
{
switch(index)
{
case 1 :
leave=true; break;
case 2 :
leave=false; break;
default:
leave=-1; break
}
return leave;
}
執行Notification.confirm經過編譯所以在這裏不等待用戶響應並轉到下一行(但對於Window,確認是這樣做的)。 所以現在我的疑問是如何重構這段代碼,以便mu離開方法將返回適當的離開值到它的耦合方法。因爲在我的回調方法執行混合應用程序中的用戶交互後shouldLeave完成其執行。所以它不像$ window.confirm功能。
任何建議表示讚賞。
謝謝伊姆蘭。我知道這種方法,但我的要求是不同的。聽起來像我需要重構我的代碼。 – Baidyanath 2015-01-21 15:57:11