我有一個自定義列表項組件與<ng-content>
作爲模板:動態添加span標籤鏈接裏面<ng-content></ng-content>
import { Component, Input } from '@angular/core';
@Component({
selector: '[my-list-item]',
template: '<ng-content></ng-content>'
})
export class MyListItemComponent {
@Input() active = false;
}
用戶可以設定活動狀態。
<ul>
<li my-list-item [active]="true">
<a href="#">Stackoverflow</a>
</li>
</ul>
如果活動的標誌被設置爲true,我一定要添加鏈接內的自定義範圍標記,它應該呈現這樣的:
<ul>
<li>
<a href="#">
<span class="active">Stackoverflow</span>
</a>
</li>
</ul>
什麼在angular2推薦的方式來完成這個? 感謝您的任何意見