0

모델 변경 목록을 업데이트하려고하지만 일부 경우 ng-repeat가 작동하고 때로는 그다지 도움이되지 않는 사람이 나를 도울 수 있습니까? 각도를 지정합니다. jQuery를에서 함수 코드는 다음과 같습니다ng-repeat가 모델 변경시 업데이트되지 않음

angular.element($('#updateGroupPannel')).scope().prepareToUpdate(group); 

이 호출되는 각 기능과 각 코드 :

:

$scope.prepareToUpdate = function(group) 
{ 
    $scope.groupId = group.id; 
    $scope.usersPageChanged(); 
    $scope.adminsExistingPageChanged(); 
} 
$scope.usersPageChanged = function() 
{ 
    workbenchService.usersUnderAdminList($scope.currentUserPage).then(function(data) 
    { 
     $scope.usersExisting = data; 
    }) 
}; 
$scope.adminsExistingPageChanged = function() 
{ 
    workbenchService.groupAdminsList($scope.currentExistingAdminPage, $scope.groupId).then(function(data) 
    { 
     $scope.editGroup.admins = data; 
    }) 
}; 

이 사용자와 관리자의 목록을 채우는 HTML 코드는

<form name="GroupUpdate" id="updateGroupPannel" ng-controller="updateController"> 
    <div ng-repeat="user in editGroup.appUsers track by $index"> 
     <div class="panel panel-default"> 
     <div>{{user.name}}</div> 
    </div> 

    <div ng-repeat="admin in editGroup.admins track by $index"> 
     <div class="panel panel-default"> 
      <div>{{admin.name}}</div> 
     </div> 
    </div> 
</form> 

문제는 때때로 NG-반복 $ scope.usersExisting 업데이트됩니다하지만 때로는 어떤 도움이 높게 평가되고, 업데이트됩니다 나던, 감사

+0

계속하기 전에 왜 jQuery에서 각도 함수를 호출하고 있는가? 실제로이 작업을 수행해야하는 경우는 거의 없습니다. –

+0

jsTree 플러그인을 사용하는 프로젝트에서 작업 중이므로 옵션이 없지만 트리 노드를 선택하면 jquery에서 angle을 호출해야합니다. . 이것을 달성하는 더 좋은 방법은 나를 알려 주시기 바랍니다, 답장 덕분에 –

+0

네이티브 앵글 트리 구현이 필요할 수 있습니다. 나는 하나 가지고 있으며 당신과 그것을 공유 할 수 있습니다. 그것은 가득 차있는 json를 입력으로 얻고 체크 박스의 나무 구조를 표시한다. 체크 된 값의 ID 인 경우 컨트롤의 값은 배열입니다. 또한 데이터를 복원 할 수 있습니다. 필요한 경우 코드를 제공 할 수 있으므로 필요에 맞게 사용자 정의 할 수 있습니다. – megapotz

답변

0

는 진드기 누군가를 위해 도움이 될 나는이 대답을 게시하고 같은 문제가 붙어있어, 여기에 문제가 쇠사슬에 묶여 있지 않았다. 나는 다음과 같이 변경했다. 이제는 완벽하게 작동한다.

$scope.prepareToUpdate = function(group) 
{ 
    $scope.groupId = group.id; 
    $scope.usersPageChanged().then(function(){ 
     $scope.adminsExistingPageChanged(); 
    }); 
} 
$scope.usersPageChanged = function() 
{ 
    var promise = workbenchService.usersUnderAdminList($scope.currentUserPage).then(function(data) 
    { 
     $scope.usersExisting = data; 
    }) 
    return promise; 
}; 
$scope.adminsExistingPageChanged = function() 
{ 
    var promise = workbenchService.groupAdminsList($scope.currentExistingAdminPage, $scope.groupId).then(function(data) 
    { 
     $scope.editGroup.admins = data; 
    }) 
    return promise; 
}; 
관련 문제