I have an angular JS application that when after loading the webpage updates (rewrites) the url param based on what the original url was. For eg if the url was www.example.com/test1 it might rewrite it to www.example.com/test1?xyz=abc and for www.example.com/test2 it might redirect to www.example.com/test2?xyz=def. My goal is that the results are picked up by the search engines as www.example.com/test1 (i.e. without the params).
Google always index the redirected/final/render version of URL (i.e. ?xyz=def). It's not possible to achieve with canonical link tag as well. I have seen some of question like this on Google offical hangout that, why Google ignore their canonical link tag, and Google official webmaster team said that, it is ignored because of redirection. Google gives more priority on redirection compare to any other method. They want to index those things that real users can see it. By displaying other things to user and Googlebot are consider as cloaking.