Angular 2组件树

时间:2016-07-06 13:23:28

标签: dependency-injection angular angular2-template angular2-directives angular2-components

我正在使用Angular 2开发我的第一个应用程序,我已经为Google Chrome安装了Augury插件,以帮助我调试代码。

这是组件树和图:

enter image description here

enter image description here

这是我的自定义组件(DocumentsList)的HTML模板:

<div class="container-fluid" style="margin-top: 10px">
    <div class="table-row header">
        <div class="column index">#</div>
        <div class="wrapper attributes">
            <div class="wrapper title-comment-module-reporter">
                <div class="wrapper title-comment">
                    <div class="column title">Title</div>
                    <div class="column comment">Comment</div>
                </div>
                <div class="wrapper module-reporter">
                    <div class="column module">Module</div>
                    <div class="column reporter">Reporter</div>
                </div>
            </div>
            <div class="wrapper status-owner-severity">
                <div class="wrapper status-owner">
                    <div class="column status">Status</div>
                    <div class="column owner">Owner</div>
                </div>
                <div class="column severity">Severity</div>
            </div>
        </div>
        <div class="wrapper icons">
            <div title="Watch" class="column watch">
                <span class="glyphicon glyphicon-eye-open"></span>
            </div>
            <div title="Add comment" class="column add-comment">
                <span class="glyphicon glyphicon-comment"></span>
            </div>
        </div>
        <div class="wrapper dates">
            <div class="column date">Created</div>
            <div class="column date">Updated</div>
            <div class="column date">Due</div>
        </div>
    </div>

    <div *ngFor="let document of docs" class="table-row">
        <div class="column index">{{document.id}}</div>
        <div class="wrapper attributes">
            <div class="wrapper title-comment-module-reporter">
                <div class="wrapper title-comment">
                    <div class="column title">{{document.title}}</div>
                    <div class="column comment">{{document.comment}}</div>
                </div>
                <div class="wrapper module-reporter">
                    <div class="column module">{{document.module}}</div>
                    <div class="column reporter">{{document.reporter}}</div>
                </div>
            </div>
            <div class="wrapper status-owner-severity">
                <div class="wrapper status-owner">
                    <div class="column status"><span class="label" [ngClass]="{'Open': 'label-primary', 'In Progress': 'label-success'}[document.status]">{{document.status}}</span></div>
                    <div class="column owner">{{document.owner}}</div>
                </div>
                <div class="column severity high">{document.severity}}</div>
            </div>
        </div>
        <div class="wrapper icons">
            <div class="column watch"><span class="glyphicon glyphicon-eye-open" [class.active]="document.watched"></span></div>
            <div class="column add-comment"><span class="glyphicon glyphicon-comment" [class.active]="document.commented"></span></div>
        </div>
        <div class="wrapper dates">
            <div class="column date">{{document.created}}</div>
            <div class="column date">{{document.updated}}</div>
            <div class="column date">{{document.due}}</div>
        </div>
    </div>
</div>

由于图中的spandiv的子项,其中有*ngFor指令,因此不应该在图表中显示为{{1}的父项1}}?

我认为图形应该看起来像这样(使用Paint创建的图像)

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:2)

简短的回答,是的。这很有道理。