我有默认/硬编码的选择选项(4个选项)和json数据。因为我的json obj中缺少了"SWIZ“的数据。当我点击它时会产生奇怪的输出。你可以看到小提琴.由于某种原因,https://jsfiddle.net/tffv2owp/6/和我必须在选择框中保留"SWIZ“选项。当我从选择下拉选项中选择"SWIZ“选项时,我需要为所有范围项目设置"0”值。
$scope.months =
[{ "country": "UK", "mon": "JAN", "A": "14", "S": "2"},
{ "country": "AUSTRIA", "mon": "JAN", "A": "24", "S": "12"},
{ "country": "ITALY", "mon": "JAN", "A": "5", "S": "21"},
{ "country": "UK", "mon": "FEB", "A": "4", "S": "12"},
{ "country": "AUSTRIA", "mon": "FEB", "A": "24", "S": "12"},
{ "country": "ITALY", "mon": "FEB", "A": "15", "S": "1"}
];
$scope.countries = ["UK", "AUSTRIA", "ITALY", "SWIZ"];发布于 2015-08-03 13:31:18
把你的小提琴叉开
https://jsfiddle.net/g81a10ze/1/
if(fData.length > 0){
this.filteredData = fData;
} else {
this.filteredData = [{ "country": "SWIZ", "mon": "JAN", "A": "0", "S": "0"},
{ "country": "SWIZ", "mon": "FEB", "A": "0", "S": "0"}]
}发布于 2015-08-03 13:38:26
你可以试试这个:
if(fData.length > 0){
this.filteredData = fData;
} else {
this.filteredData = [{},{}];
}`在html中
<tr>
<td>{{selectedCountry=='SWIZ'?0:month.A}}</td>
</tr>
<tr>
<td>{{selectedCountry=='SWIZ'?0:month.S}}</td>
</tr>https://stackoverflow.com/questions/31788395
复制相似问题