1
JSPAngularjs data-ng-click不會再次工作......怎麼樣?
頁<form>
<table class="countrys" data-name="tableCountry">
<tr bgcolor="lightgrey">
<th>Country ID</th>
<th>Country Name</th>
</tr>
<tr data-ng-repeat="c in allCountrys"
data-ng-click="selectedCountry(c, $index);"
data-ng-class="getSelectedClass(c);">
<td>{{c.countryId}}</td>
<td>{{c.countryName}}</td>
</tr>
</table>
</form>
控制器
$scope.selectedCountry = function(country, index){
angular.forEach($scope.allCountrys,function(value, key) {
if (value.countryId == country.countryId) {
$scope.selectedCountry = country;
}
});
$scope.selectedRowCountry = index;
}
$scope.getSelectedClass = function(country) {
if ($scope.selectedCountry.countryId != undefined) {
if ($scope.selectedCountry.countryId == country.countryId) {
return "selected";
}
}
return "";
};
CSS
tr.selected {
background-color: #aaaaaa;
}
有我的網頁上這個表,一旦我按1行,它會選擇它,它改變了顏色,它在兩個功能...
但一旦我點擊另一行,我t不會去selectedCountry函數,但只能進入sgetSelectedClass函數
我不知道爲什麼,我只是想要能夠選擇一行,然後另一個等等......所以總是隻有一行是選擇
你能幫助我嗎?
hu,我剛發現。 –
thx男人,你救了我.... – aaaaaaaa1