Multiple url in $routeProvider

白昼怎懂夜的黑 提交于 2019-12-10 18:13:37

问题


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:


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.



来源:https://stackoverflow.com/questions/37284707/multiple-url-in-routeprovider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!