我想根據國家顯示獨特的頁面。我指的是耐克網站。 https://www.nike.com/sg/en_gb/。在這裏,用戶可以選擇一個地區/國家:基於國家的路由
如何使用路由參數而不是路徑來實現。我想實現使用路由參數或更好的解決方案(如果有的話)。
查看
<body ng-controller="CountryController">
<form>
<select name="naver" id="naver" ng-model="route.selectedRoute" ng-change="RedirecttoCountry(route.selectedRoute)">
<option value="/" >Home</option>
<option value="/US">US</option>
<option value="/UK">UK</option>
<option value="/India">India</option>
</select>
</form>
<div ng-view=""></div>
我對每一個國家單獨HTMLS。
控制器
var app = angular.module("myApp", ['ngRoute']);
app.config(function($routeProvider){
$routeProvider
.when('/', {
templateUrl: "US.html",
controller: 'CountryController'
})
.when('/UK', {
templateUrl: "UK.html",
controller: 'CountryController'
})
.when('/India', {
templateUrl: "India.html",
controller: 'CountryController'
})
.otherwise({ redirectTo: '/' });
});
app.controller('CountryController', function($scope, $location){
$scope.RedirecttoCountry = function(path){
$location.path(path);
}
});
如果我是正確的,你可以通過執行'/添加PARAM:country' –