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