Angular模态文本框没有被NGMODEL填充



我有一个带有电视节目数据的表。我用dir-paginate/ng-repeat填充表,我可以单击一行以打开模式以编辑表演,但是NG模型数据没有在该模式的文本框上加载。

<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>

单击时,它调用函数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 () {
    });
}

传递的数据以JSON形式如下:

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

我传递了节目详细信息,并将其设置为$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>

我该如何将其填充文本框,其中包含单击的行中的详细信息?

我已经设法使用ModalInstance的Resolve弄清楚了。

$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;
});

最新更新