Angular JS button links are sometimes tied to the a specific route defined on the router file. However, sometimes we would like to AB test links on those buttons. Modifying those button links with Visual Editor changes or code in the Code Editor or Variation Custom JS code might not be possible, as the processing of this links depends on the router configuration of your app.
The solution is to make the router conditionally select another route depending on the variation that has been selected. For this we would need to edit the router configuration and build the application again.
So, here we are going to provide some example code:
If it returns undefined, the second route will be taken, which would correspond to the original variation.
You can read where to find the experiment and variation id's in the following article.