Firefox-only - Angular runs into problem with a query parameter named 'watch' #8068
Description
In Firefox only, this line of code: $location.path(window.location.pathname).search('watch=online');
Produces this output in the browser:
http://local.xxx.com/entertainment?watch=function%20watch%28%29%20{%0A%20%20%20%20[native%20code]%0A}&watch=online
Notice the two watch params. I think one is somehow picking up a $scope.watch() function. This line is contained within a $scope.watch function itself.
However if we change the query parameter name to anything else, like watch2 or Watch, the output comes as expected.
$location.path(window.location.pathname).search('Watch=online');
http://local.xxx.com/entertainment?Watch=online
Here is the full function:
$scope.$watch('filters', function(newValue, oldValue){
if(!_.isEqual(oldValue, newValue)){
// update url based on selected filters when it's not deeplinking
$location.path(window.location.pathname).search('Watch=online');
}
}, true);
FYI - I also tried just setting the search manually using window.location.search = 'watch=online'. That works but also reloads the page as expected. What happens next is interesting - angular once again sees the url and adds the second watch param - with the same native function property.