Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. // GET parameter to search variable
  2. $scope.$watch(function() {
  3. return $location.path();
  4. }, function(path) {
  5. $scope.query =path.substr(1).split(/(?:\s|,)+/);
  6. };
  7.  
  8. // Search variable to GET parameter
  9. $scope.$watch('query', function(newValue, oldValue) {
  10. if (newValue && newValue != oldValue && $location.path().substr(1) != newValue) {
  11. $location.path('/search/'+newValue);
  12. }
  13. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement