Angular 2 components tree

浪子不回头ぞ 提交于 2019-12-13 22:24:24

问题


I'm developing my first application with Angular 2 and I have installed Augury plugin for Google Chrome, in order to help me debug the code.

Here's the components tree and graph:

This is the HTML template of my custom component (DocumentsList):

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

Since the span in the graph is child of a div in which there is a *ngFor directive, shouldn't it be displayed in the graph as the parent of the span?

I think the graph should've looked like this (images created with Paint)


回答1:


Short answer, yes. It makes sense.



来源:https://stackoverflow.com/questions/38225172/angular-2-components-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!