하나의 문제점이 있습니다. 난 그냥 NG-반복 내 편집 양식을 defind 때 객체AngularJS ng-show 동적이 올바르게 작동하지 않습니다.
<tr ng-repeat="account in accountLst">
<td ng-hide="edit{{account.accountName}}">
{{account.fullName}}
</td>
<td ng-show="edit{{account.accountName}}">
I want to show this line and hidden other!
</td>
<td ng-hide="edit{{account.accountName}}">
{{account.accountName}}
</td>
<td ng-hide="edit{{account.accountName}}">
{{account.email}}
</td>
<td>
<button ng-click="editaccount(account)">Edit</button>
</td>
</tr>
그리고 이것은 내 editaccount 기능입니다
$scope.editaccount = function (obj) {
var res = false;
var tmp = 'edit'.concat(obj.accountName);
for(var i = 0; i < $scope.accountLst.length; i++) {
if(angular.equals(obj.accountName, $scope.accountLst[i].accountName)) {
res = true;
break;
} else if(!angular.equals(obj.accountName, $scope.accountLst[i].accountName)){
res = false;
}
}
//$scope.edit123 = true;
$scope.$tmp = res;
console.log(tmp + ' is ' + $scope.$tmp);
return res;
}
모든 제외하고 잘 작동과 클릭 버튼 '편집'
예, I 입력 accountName = '123', then
$ scope.edit123 = true를 정의하면; => 작동,
through $ scope. $ tmp = true; => 더 이상 작동하지 않습니까? (tmp = edit123 너무);
제발 도와주세요 - 나는 초보자입니다.
여기 내 코드는 https://jsfiddle.net/otp3ooyd/3/
당신이있어 그 피들러를 JS ... 플러스 문자열 값이 falsy/trusy ... – Leo
@로 평가하지 않는 오류 비. 나는 당신의 코드 검증에 의문을 갖고있다. 나는 그것이 AND (&&) - – MukulSharma
@Leo 알아요, 하나의 파일로 합치면 잘 될 것입니다! – Rain