0
我的选择外观上的文本框NG-模型值页面加载的基础是这样的:动态选择选项时,在角
<select onchange="getVideo()" id="region">
<option ng-repeat="items in region" ng-selected = "items.countryCode === selectedRegion" value="{{items.countryCode}}">{{items.countryCode}}</option>
</select>
这是我的JSON:
$scope.region = [
{
countryItem : "TW(TW)",
countryCode : "tw_zh_tw"
},
{
countryItem : "US(EN)",
countryCode : "us_en"
},
{
countryItem : "US(ES)",
countryCode : "us_es"
},
{
countryItem : "JP(JA)",
countryCode : "jp_ja"
},
];
当选择框改变,它会调用一个函数getVideo()函数:
function getVideo() {
var language = $("#region option:selected").val();
location.href="/support/"+language+"/Videobackstage;
}
使用此函数,页面始终会在选择变长时加载es,所以即使页面加载,我也需要保留select的值。
为了解决我提出的解决方案,我使用文本框ng模型作为ng选择条件的参数,文本框有一个值,它以我想要的方式工作,但对于选择它是不工作:
<input type="text" ng-model="selectedRegion" id="selectedRegionx">
我通过在URL中得到一个特定的值设置文本框的值:
$(document).ready(function(){
var pageUrl = window.location.pathname;
var split = pageUrl.split("/");
var langUrl = split[2];
$("#selectedRegionx").val(langUrl);
});