2017-04-26 1 views
0

TV 쇼 데이터가있는 테이블이 있습니다. dir-paginate/ng-repeat 테이블을 채우고 행을 클릭하여 쇼를 편집 할 수있는 모달을 열 수 있지만 ng 모델 데이터는 해당 모달 내의 텍스트 상자에로드되지 않습니다. 나는 쇼 세부 사항을 전달하고로 설정ngModel로 채워지지 않는 모달 텍스트 상자

{"watched":false,"id":1,"show_name":"The Walking Dead","season":1,"episode":1,"season_episode":"Season 1, Episode 1","$$hashKey":"object:4"} 

: 클릭하면

<tr id='schedule_row' class='hover_click_cell' dir-paginate='tv_show in tv_shows | orderBy:sortType:sortReverse | itemsPerPage:10'> 
<td class='center_text clickable_cell cell_width' ng-click='alter_show(tv_show)'>{{tv_show.show_name}}</td> 

, 그것은 기능을 JSON 형태로 다음과 같은 외모를 통과 alter_show()

$scope.alter_show = function(show) 
{ 
    $scope.edit_show = show; 
    var modalInstance = $uibModal.open ({ animation: $controller.animationsEnabled, 
               ariaLabelledBy: 'modal-title', 
               ariaDescribedBy: 'modal-body', 
               templateUrl: 'edit_tv_show.html', 
               controller: 'EditTvShowCtrl', 
               controllerAs: '$controller', 
               size: 'sm', 
               backdrop: 'static', 
               keyboard: false 
             }); 

    modalInstance.result.then(function (action) 
    { 

    }, 
    function() { 
    }); 
} 

데이터를 호출 $scope.edit_show 개체입니다. 전달되는 데이터는 비어 있지 않지만 모달이 열리면 텍스트 상자가 채워지지 않습니다. 다음은 입력 상자입니다.

$scope.edit_show = { 
    show_name: '', 
    season: 0, 
    episode: 0, 
    watched: 0 
}; 

<div class='form-group'> 
<label for='show_name'>Show Name:</label> 
<input type='text' class='form-control' id='edit_show_name' ng-model='edit_show.show_name'> 
</div> 

<div class='form-group'> 
<label for='season'>Season:</label> 
<input type='number' class='form-control' id='edit_season' ng-model='edit_show.season'> 
</div> 

어떻게하면 클릭 한 행의 세부 정보로 텍스트 상자를 채울 수 있습니까?

+0

텍스트 상자가 채워지지 않거나 값이 바인딩되지 않습니까? –

답변

0

modalInstance에 대한 해결 방법을 사용하여 해결할 수있었습니다.

$scope.alter_show = function(show) 
{ 
    var modalInstance = $uibModal.open ({ animation: $controller.animationsEnabled, 
               ariaLabelledBy: 'modal-title', 
               ariaDescribedBy: 'modal-body', 
               templateUrl: 'edit_tv_show.html', 
               controller: 'EditTvShowCtrl', 
               controllerAs: '$controller', 
               size: 'sm', 
               backdrop: 'static', 
               keyboard: false, 
               resolve: { tv_show : function() { return show; } } 
             }); 

    modalInstance.result.then(function (action) 
    { 

    }, 
    function() { 
    }); 
} 

angular.module('ui.bootstrap').controller('EditTvShowCtrl', function ($uibModalInstance, $scope, tv_show) 
{ 
    var $controller = this; 

    $scope.edit = tv_show; 
});