简体   繁体   中英

Navigates of page programmatically but address bar URL doesn't changes

I am using J-Query Mobile and AngularJS and on the pressing link i want navigate user to different page it navigates but url address in address bar doesn't change how to solve this issue. I ma using the single page structure

HTML Part

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

I solved my issue
If you use Angular-JS , JQuery Mobile and also Angular JQM Adopter then you can achieve your requirement by change your code from

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

To this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM