title: angularJS set route params in controller
body: <p>I have an app which creates several surveys with random survey ids. As the ids are generated in the backend they are set in the controller. I read the documentation on that, however I do not really understand how to set the routeparams in order to always reach the page /survey/:surveryID.</p>
  
  <p>Here is my code so far:</p>
  
  <p>App Config:</p>
  
  <pre><code>...
   .when('/survey/:surveyId', {
          templateUrl: 'views/survey.html',
          controller: 'SurveyCtrl',
          controllerAs: 'survey'
        })
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>function SurveyCtrl($scope, RequestService, _, $location, $routeParams) {
  
    $scope.go = function () {
      $location.path('/#/survey/' + Math.random());
    };
  }
  </code></pre>
  
  <p>View with the link to /survey/:surveyId:</p>
  
  <pre><code>  &lt;div&gt;
      &lt;md-button ng-click="go()"&gt;Enter Survey&lt;/md-button&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>I know that this is not the right way and it is not even working. Can someone tell me how to dynamically create these params and set them in the controller so I can access the link with a button and then when clicked reach the survey/:surveyId page?</p>