我有一個表,並希望顯示/隱藏按下按鈕時每列的描述。 我有什麼視覺: the tableAngularJS。 ng-show,ng-click沒有按按鈕的工作
正如你在我的HTML看,我宣佈一個按鈕,一個NG單擊作爲這需要一個參數相匹配的NG-顯示的功能。
但按鈕被按下時它什麼也不做,爲什麼?
我的HTML:
<table>
<tr>
<td><strong>Data</strong></td>
<td><strong>tempmin</strong></td>
<td><strong>tempmax</strong></td>
<td><strong>umiditatea</strong></td>
<td><strong>presiunea</strong></td>
<td><strong>vitezavint</strong></td>
<td><strong>nori</strong></td>
</tr>
<tr ng-repeat="md in chisinau.list">
<td class='td'><span ng-show='buton0'>
{{md.dt * 1000 | date:"MM.dd"}}</span></td>
<td class='td'><span ng-show='buton1'>
{{md.temp.min}}</span></td>
<td class='td'><span ng-show='buton2'>
{{md.temp.max}}</span></td>
<td class='td'><span ng-show='buton3'>
{{md.humidity}}%</span></td>
<td class='td'><span ng-show='buton4'>
{{md.pressure}}</span></td>
<td class='td'><span ng-show='buton5'>
{{md.speed}}</span></td>
<td class='td'><span ng-show='buton6'>
{{md.clouds}}</span></td>
</tr>
<tr>
<td ng-repeat='buton in butoane track by $index'>
<button ng-click="fbuton('buton'+$index)">{{buton}}</button>
</td>
</tr>
我controller.js:
$http.get('http://api.openweathermap.org/data/2.5/forecast/daily?q=Chisinau&mode=json&units=metric&cnt=10&appid=6fa04faec9c89ba8cf92dd1f76e7d518')
.success(function(response){
$scope.chisinau = response;
});
$scope.butoane = [
'buton-data',
'buton-tempmin',
'buton-tempmax',
'buton-umidiatea',
'buton-presiunea',
'buton-vitezavint',
'buton-nori'
];
$scope.buton0 = true;
$scope.buton1 = true;
$scope.buton2 = true;
$scope.buton3 = true;
$scope.buton4 = true;
$scope.buton5 = true;
$scope.buton6 = true;
$scope.fbuton = function(x){
$scope.x = $scope.x == true ? false : true;
}
無關,與你所面臨的問題,但是你可以簡化'$ scope.x = $ scope.x ==真的嗎? false:true;'通過'$ scope.x =!$ scope.x' –
你如何檢查$ scope變量'x'確實改變了?我沒有看到它在你看來,也沒有看到'console.log()'... – MarcoS