AngualrJS routeProvider路由到错误的模板

MCh*_*han 4 angularjs angularjs-routing

我在我的app.js文件中有以下2条路线,由于某种原因我不知道何时尝试导航到/clients/new-invoice我看到/clients/:clientID路线和模板.我可以转到正确页面的唯一方法是删除/clients/:clientID路线.

我也注意到,只有在我添加:clientID到下面的路线后才开始发生这种情况.

有人可以通过告诉我我在这里做错了什么来帮助我吗?

    $routeProvider.when('/clients/:clientID', 
            {     templateUrl: 'templates/client-profile-view.html', 
                  controller: 'ClientsController',
                  title: 'Client Profile',
                  data: {
                     auth: true,
                     plevel: [5] 
                  }                
            });    


    $routeProvider.when('/clients/new-invoice', 
            {     templateUrl: 'templates/new-invoice.html', 
                  controller: 'InvoicesController',
                  title: 'New Invoice',
                  data: {
                     auth: true,
                     plevel: [5] 
                  }                
            });
Run Code Online (Sandbox Code Playgroud)

yag*_*ger 7

你只需要改变顺序,放在/clients/:clientID后面/clients/new-invoice.订单很重要.应在静态路径之后定义所有正则表达式路径.