2016-08-30 2 views
0

하나의 문제점이 있습니다. 난 그냥 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/

+1

당신이있어 그 피들러를 JS ... 플러스 문자열 값이 falsy/trusy ... – Leo

+0

@로 평가하지 않는 오류 비. 나는 당신의 코드 검증에 의문을 갖고있다. 나는 그것이 AND (&&) - MukulSharma

+0

@Leo 알아요, 하나의 파일로 합치면 잘 될 것입니다! – Rain

답변

0

$ scope. $ tmp = true 다음에 세미콜론을 지정해야합니다.

jsfiddle 코드에서 동일한 것을 확인했습니다.

+0

제가 할 수있는 한 무엇이든 시도했지만 여전히 같은 문제가 있습니다. 이 실수는 코드를 복사 할 때 발생합니다. – Rain

0

이렇게하면 효과가있을 수 있습니다.

VAR의 tmp = "edit123" $ 범위 [TMP] = 사실

+0

내 전체 코드를 참조하십시오, edit123 그냥 내 테스트 때 accountName = '123' – Rain

관련 문제