Multiple url in $routeProvider

2019-07-02 23:49发布

I want to redirect multiple url for $routeProvider. How can I apply this? For example, I am trying like this,

.when('/laptop' || '/mobile', {
     templateUrl: '/Selection_Routing/Selection_Product/ProductDetails.html',
     controller: 'ProductDetailsController'
     })

Please note that I want to redirect either /laptop or /mobile url, but it is not working. Any suggestion?

1条回答
三岁会撩人
2楼-- · 2019-07-03 00:28

I do something similar with UI Router.

var sameURL = "laptop,mobile,foo,bar".split(",");
angular.forEach(sameURL function(route) {
     .state(route, {
          url: "/" + route,
          templateUrl: "views/home.html"
      })
})

You should be able to adapt this easily.

查看更多
登录 后发表回答