I have function in AngularJS which uses the $location.path
. Everything works fine on my desktop computer, however when I tried to use it on my iPhone or Android Tablet it doesn't change the path.
I read to include $scope.apply()
; after the $location.path
, this isn't working for me. Furthermore I included two alerts to see if the function is fired. Alert: Test1 and Alert: Test2 are fired.
app.controller('matchesCtrl', ["$scope", "$modal", "$filter", "$interval", "$translate", "Data", "$localStorage", "$location", function($scope, $modal, $filter, $interval, $translate, Data, $localStorage, $location) {
$scope.BeginMatch = function(c) {
alert('Test1');
Data.put('match/umpire/' + $scope.$storage.id, $scope.$storage).then(function() {
alert('Test2');
window.navigator.vibrate(200);
$location.path('match/warmup/' + $scope.$storage.id);
$scope.$apply();
});
};
}]);
The path should be changed to match/warmup/"id"
, but the path stays the same as before.
After more than 4 hours I figured out the mistake. window.navigator.vibrate(); is not supported by browsers on mobile devices. Sorry for the inconvience.
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.