2014-10-20 71 views
1

我陷入了一個問題,我必須在離子框架中使用控制器打開特定頁面。 我得去下頁轉到離子框架中的特定頁面

#/tab/hotel_details/1 

當我在離子彈出窗口

$scope.showAlert = function() { 
    var alertPopup = $ionicPopup.alert({ 
    title: 'Click OK for further details', 
    }); 
    alertPopup.then(function(res) { 
    //Go to a specific page 
    }); 
}; 

我不能使用$state.go("tab.hotel_details");單擊確定按鈕,因爲我必須去hotel_details/1 我得擺脫上述問題進一步發展我的應用程序。

+0

可能重複[離子模板內容不適用翅膀](http://stackoverflow.com/questions/23242075/ionic-template-content-not-showing) – 2014-10-21 02:43:43

回答

7

您可以在通話的第二個參數傳遞的ID來$state.go

$state.go("tab.hotel_details", { "id": id }) 

然後,在你的控制器,你可以從$stateParams值:

var id = Number($stateParams.id) 

參考:Angular-ui State

-1

如果您想導航到特定的網址而不是通過狀態進行導航,則仍然可以使用$位置服務。

$location.path('/tab/hotel_details/1'); 
+0

這對我來說沒有任何作用,但接受的答案確實工作。 – 2016-01-14 00:24:54