2013-09-28 79 views
1

我使用J-Query MobileAngularJS,並且在我要導航用戶到不同頁面的按壓鏈接上導航,但地址欄中的url地址不會更改如何解決此問題。我是個使用單頁結構以編程方式瀏覽頁面,但地址欄URL不更改

HTML部分

<a href="" ng-controller="addFoodToLog" ng-click="go()" data-role="button">Add To Log</a> 

JS部分

var myApp = angular.module('myApp',[]); 

myApp.controller('addFoodToLog',function($scope){ 
    $scope.go = function() { 
    //Here Selected Food Bump In Food Log 
    alert("Successfully Add In Your Log"); 
    $.mobile.changePage('index.html#foodscreen'); 
    } 
}); 
+0

有人問它
之前http://stackoverflow.com/questions/7824243/jquery-mobile-mvc-getting-the-browser-url-to-change-with-redirecttoaction 你必須禁用移動阿賈克斯。看鏈接。 – Dvir

+0

其中我禁用移動阿賈克斯 – Blu

+0

@Dvir 我補充說,但沒有效果 Add To Log Blu

回答

0

我解決我的問題
如果使用Angular-JSJQuery MobileAngular JQM Adopter那麼你可以達到你的要求通過更改您的代碼

myApp.controller('addFoodToLog',function($scope){ 
    $scope.go = function() { 
    //Here Selected Food Bump In Food Log 
    alert("Successfully Add In Your Log"); 
    $.mobile.changePage('index.html#foodscreen'); 
    } 
}); 

對此

myApp.controller('addFoodToLog',function($scope,$location){ 
    $scope.go = function() { 
    //Here Selected Food Bump In Food Log 
    alert("Successfully Add In Your Log"); 
    $location.hash('foodscreen'); 
    } 
}); 
相關問題