简体   繁体   English

角加载后运行jQuery

[英]Run jQuery after angular loads

I'm trying to style a table that is rendered with ngRepeat based on JSON that is received using a service that uses $http.get . 我正在尝试使用使用$http.get的服务接收的基于JSON的ngRepeat呈现的表格样式。

The problem is that I have side headers and I want to do a border-left like in this picture, but I can't with CSS. 问题是我有侧标题,我想在这张图片中做一个边框左边,但我不能用CSS。

My code is here: http://embed.plnkr.co/V2E0rLJVVOgOlGLzmrER/preview 我的代码在这里: http//embed.plnkr.co/V2E0rLJVVOgOlGLzmrER/preview

So I need to run jQuery to style the table with better selectors. 所以我需要运行jQuery来为表格设置更好的选择器。

Note that the table is populated in a function inside a controller. 请注意,该表填充在控制器内的函数中。

The problem is that I can't do: .frm-tr:first-child td{border-left: "solid"} , and inside the controller, after I get the data, I can't manipulate the DOM that is created inside the service .success function. 问题是我不能这样做: .frm-tr:first-child td{border-left: "solid"} ,在控制器内部,在我获取数据之后,我无法操纵创建的DOM在服务内部.success功能。

This returns nothing: 这没有任何回报:

My controller 我的控制器

    $scope.dashTable = data.data;
    $(document).ready(function () {
        console.log($('.frm-tr'));
    });

My angular table 我的角桌

<table cellspacing='0' cellpadding="0" border="1" ng-repeat="table in dashTable" class="frm-quota-table">
<tbody>
    <tr class="frm-table-header" ng-repeat="header in table.Header">
        <th colspan="{{cell.ColSpan}}" ng-if="cell.Index !== 0" ng-repeat="cell in header.Cells" class="frm-headers clearfix" ng-class="{'border-left':cell.ColSpan === 1}">
            <div ng-if="cell.Text !== '' && cell.ColSpan !== 1" class="frm-table-line pull-left"></div>
            <div ng-class="{'pull-left cell-text': cell.Text !== '' && cell.ColSpan !== 1}">{{cell.Text}}</div>
            <div ng-if="cell.Text !== '' && cell.ColSpan !== 1" class="frm-table-line pull-right"></div>
        </th>
    </tr>
    <tr class="frm-tr" ng-repeat="content in table.Content">
        <th ng-if="th.RowSpan !== 1" rowspan="{{th.RowSpan}}" colspan="{{th.ColSpan}}" class="frm-side-header" ng-repeat="th in content.LeftPart">
            --&nbsp;{{th.Text}}&nbsp;--
        </th>
        <th ng-if="th.RowSpan === 1" rowspan="{{th.RowSpan}}" colspan="{{th.ColSpan}}" ng-repeat="th in content.LeftPart">
            {{th.Text}}
        </th>
        <td ng-repeat="td in content.ContentPart">
                {{td.Text}}
        </td>
    </tr>
</tbody>
</table>

After discussions with other developers in my team, we did it in angular in a different style: 在与我的团队中的其他开发人员讨论后,我们以不同的风格进行角度测试:

Solution: 解:

<td ng-repeat="(ndx, td) in content.ContentPart" ng-class="{'border-left-simple': ndx % 3 === 0}"> {{td.Text}} </td>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM