2014-05-21 2 views

답변

22

각도 UI의 모달은 $rootScope으로 기본값은 (See the documentation here)입니다.

모달을 열 때 사용자 정의 범위와 함께 scope 매개 변수를 전달할 수 있습니다 (예 : 부모 범위를 전달하려면 scope: $scope. 모달 컨트롤러는 해당 범위에서 하위 범위를 생성하므로 초기 값으로 만 사용할 수 있습니다.

+1

제공된 의사가 존재하지 않으므로 새로운 것을 제공 할 수 있습니까? – fuyi

+0

분명히 문서를 앵커 링크 할 수 없습니다. 문서로 이동하여 * 모달 * 표제를 찾으십시오. – lyschoening

+0

상위 범위 값이 변경되면 하위 범위를 동적으로 업데이트하는 솔루션은 무엇입니까? 내 모달에 표시된 데이터를 업데이트하는 데이터 폴링 이벤트가 있고 동적으로 업데이트하기를 원하기 때문에이 작업은 필자에게 중요합니다. 감사! – tpartee

1

부모 div에 ID를 추가하고 범위를 사용할 수 있습니다.

<div id="outerdiv" ng-controller="OuterCtrl"> 
<h2>Outer Controller</h2> 
<input type="text" ng-model="checkBind"> 
<p>Value Of checkbind: {{checkBind}}</p> 

그리고 설정은 "가짜"컨트롤러

//init 
$scope.checkBind = angular.element(document.getElementById('outerdiv')).scope().checkBind; 

    $scope.$watch('checkBind', function (newValue, oldValue) { 
//update parent 
    angular.element(document.getElementById('outerdiv')).scope().checkBind = $scope.checkBind; 
    }); 

내에서 바인딩 http://plnkr.co/edit/u6DuoHJmOctFLFhvqCME?p=preview

13

당신은 당신의 $ 모달 옵션에서 부모 범위를 참조해야합니다 참조하십시오. 다음은 Angular documentation

Corrected Plunker Version

도 나는 그것이 작동하도록 추가 무엇의 코드입니다.

var modalInstance = $modal.open({ 
    templateUrl: 'myModalContent.html', 
    controller: ModalInstanceCtrl, 
    scope:$scope, //Refer to parent scope here 
    resolve: { 
    items: function() { 
     return $scope.items; 
    } 
    } 
}); 
관련 문제