我有一个父组件&具有模板的子组件分别如下所示:
@Component({
selector : 'my-app',
template : `<div class="container-fluid">
<div class="row page-header">
<span class=" col-lg-1"></span>
<img class="img-responsive col-xs-2" src="./app/EF Education First Logo_tcm25-388033.jpg" alt="logo"/>
<h1 class="txt-primary col-xs-9">Issues Dashboard</h1>
</div>
<div class="row">
<span class="col-xs-1"></span>
<div class="col-xs-2">
<tree-view #tree class="treeview" [treeData]=treeData ></tree-view>
</div>
<div class="col-xs-9 well content">
<!-- Tab panes -->
<comments-section></comments-section>
</div>
<div class="clearfix"></div>
</div>
</div>`,
providers:[WebApiService]
})
子组件(递归):
@Component ({
selector: 'tree-view',
template: `<ul>
<li *ngFor="let node of treeData">
<a (click)="onDateSelect($event)" href="#">{{node.name}}</a>
<tree-view *ngIf="node.subnodes" [treeData]="node.subnodes" ></tree-view>
</li>
</ul>`
})
当我在父母和父母身份中放入ngAfterViewInit()时孩子我得到以下日志(我把日志放在里面)
当我使用ngAfterContentInit()时会发生同样的事情,这对我来说非常惊讶。谁能告诉我为什么会这样呢?