javascript - Jquery 对话框未使用 Angular 范围填充

标签 javascript angularjs jquery-dialog

第一次启动对话框时,以下代码似乎不起作用。

        $scope.ke_location_channel_summary = function (region_id, region) {

        $scope.region_data = $scope.location_channel_data[region_id];

            killed_enquiries_services.open_dialog('popup', region);
            $('#popup').html($('#location_channel_summary').html());

    };

但它适用于以下更改

        $scope.ke_location_channel_summary = function (region_id, region) {

        $scope.region_data = $scope.location_channel_data[region_id];

        window.setTimeout(function () {
            killed_enquiries_services.open_dialog('popup', region);
            $('#popup').html($('#location_channel_summary').html());
        }, 0);
    };

代码的 HTML 部分是

<div id="location_channel_summary" style="display: none">
<table class="standardTable">
    <tr>
        <th class="left-col-heading">Channel</th>
        <th class="center">Qty</th>
        <th class="center">Nights</th>
        <th class="center">Value</th>
        <th class="center">Avg Value</th>
        <th class="center">ADR</th>
    </tr>
    <tr ng-repeat="ctype in contacttypes | orderBy:['sort_order']">
        <td style="width:25%;" class="left-col-td">{{ctype.name}}</td>
        <td ng-repeat="column in columns" class="center">{{region_data[ctype.id][column]}}</td>

    </tr>
</table>

我正在尝试在 Jquery 对话框上显示 div 内容。返回的表包含空白内容,没有 setTimeOut。为什么会这样?

最佳答案

这可能是因为 AngularJS 观察器是异步的,需要一些时间来解析 {{ctype.name}}{{region_data[ctype.id][column]}} 表达式。

关于javascript - Jquery 对话框未使用 Angular 范围填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31539837/

相关文章:

jquery - 刷新 (F5) 在 jQuery 对话框中不起作用

javascript - 如何让代码等待确定/取消按钮选择?

jquery - Cookie 和 Jquery : Dialog Boxes

javascript - Javascript 事件处理程序未按预期触发

angularjs - 使用 Typescript 时,我应该如何使用 $http 定义回调?

javascript - AngularJS 下拉菜单绑定(bind)

angularjs - 如何设置依赖于通过ajax加载的共享对象的 Angular 指令?

javascript - useLocation 抛出对象不是函数

javascript - 从 2 个输入获取并同时替换

javascript - 每秒在红色和绿色之间更改背景颜色