以编程方式导航页面,但地址栏URL不会更改

时间:2013-09-28 21:22:34

标签: javascript jquery-mobile angularjs

我正在使用J-Query MobileAngularJS并且在按下的链接上我希望将用户导航到导航的不同页面,但地址栏中的url地址不会更改如何解决此问题。我使用单页结构

HTML部分

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

JS Part

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');
  }
});

1 个答案:

答案 0 :(得分: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');
  }
});