AngularJS:路由的url参数

Tho*_*sch 6 parameters routing views angularjs

我想在angularjs中使用url参数进行路由

我有一个带2个视图的anguar应用程序:editView和mainView

给出一个如下所示的网址:'httx:// myapp /?param1 = x&... &editmode = 1&...'

- >将我带到/ editMode路径

这样做有什么好办法?

  • 我需要使用控制器来获取$ routeparams.editmode并使用$ location.path('/ editmode')如果editmode == 1?
  • 我需要html5模式吗?

  • 关于url我无能为力 - 我被迫使用editmode参数


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

Tho*_*sch 3

我发现我需要的是“resolve:”而不是“controller:”。如果有人有兴趣通过参数更改路线,则可以这样做: https: //github.com/angular/angular.js/issues/1838#issuecomment-13994168