angularjs: checking url location change -
i'm watching $locationchangesuccess
event. need clean way check whether url has changed or if parameters have changed. compare 'next' , 'current' parameters, maybe there's function doing ?
set custom watch:
function myctrl($scope, $location) { // watch parameters... $scope.$watch(function() { return $location.search(); }, function(newparams, oldparams) { console.log(newparams); console.log(oldparams); }, true); }
note third argument true
passed $scope.$watch()
; important ensure watch value, in case object, watched changes (and not referentially).
Comments
Post a Comment