AngularJS: url parameters for routing

I would like to use url parameters for routing in angularjs

I have an anguar app with 2 views : editView and mainView

Given a url that looks like this: 'httx://myapp/?param1=x&...&editmode=1&...'

-> will get me to the /editMode Path

What would be a good way to do so?

  • would i need to use a controller to get the $routeparams.editmode and use the $location.path('/editmode') if editmode == 1 ?
  • do i need html5 mode?

  • There is nothing i can do about the url - i am forced to use the editmode parameter


$routeProvider.when('/', {
  controller: function($routeParams, $location) {
    if($routeParams.editmode == '1') {
      $location.path('editMode') ...

I found out that "resolve:" instead of "controller:" was what i needed. If anyone is interested in changing routes via params, this is the way to go: https://github.com/angular/angular.js/issues/1838#issuecomment-13994168