Angularjs/Javascript Do not reload page, but change url and update screen -


recently have come problem need update page using angular, update url, not reload page. confused? let me further explain. have table of data (uses ng-grid) , want when click row 1 angular prints out 1 , changes url 'currenturl/1' without reloading page. click row 4, 4 prints out , changes url 'currenturl/4'. possible angular this. make page not reload every time clicked row, put following

var lastroute = $route.current;     $scope.$on('$locationchangesuccess', function(event) {         $route.current = lastroute;     }); 

which want, changes url, page doesn't reload, angular not updating number. doing wrong?

it see part of code prints out number, code changing url without refreshing route looks fine.

without more information, shot in dark controller updating $scope variable update isn't getting applied angular.

try wrapping variable update so:

$scope.$apply(function() {   $scope.numbertoprint = newnumber; }); 

the basic idea behind calling $scope.$apply have manually coax angular updating bindings listening variable. although should taken care of, possibly happening preventing route change occurring not having angular digest new variable.

here article can explain $apply better.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -