controller.js
$scope.getElectInfo=function(){
var selectedVal = $("#countriesList option:selected").val();
if (selectedVal != 0) {
$.get(APP_URL+ "/political/ElectionType/GetElectionTypesByCountry?countryId="
+ selectedVal,
function(data, status) {
$scope.data1=data;
console.log($scope.data1);
});
$scope.Structure = true;
}else
{
$scope.Structure = false;
}
}
HTML
<select id="countriesList" ng-change="getElectInfo()" ng-model="getElectionInfo">
</select>
<div ng-show="Structure" class="content">
<figure class="org-chart cf">
<ul class="administration">
<li>
<ul class="director">
<li>
<ul class="subdirector">
</ul>
<ul class="departments cf">
<li><a ><span ng-repeat="cname in country">{{cname.countryName}}</span></a></li>
<li class="department dep-b" ng-repeat="types in data1">
<a ><span>{{types.name}}</span></a>
</li>
在上面controller.js我得到全國大選明智類型的數據,在html頁面,當我第一次選擇國家$ scope.data1不更新在視圖中,選擇第二次更新可以任何一個幫助我什麼是問題!
刪除行以獲取選定值並將其替換爲您的變量getElectionInfo。 確保您的條件「!= 0」爲真,並檢查getElectionInfo的值 – Silvinus
沒有運氣,同樣的問題 – arjun
您檢查了getElectionInfo的值嗎?你確定請求正在執行並返回一個數組嗎?你能第一次提供請求結果嗎? – Silvinus