2
我用NG-內容與* ngIf一個組件內有一個奇怪的行爲,請參閱本plunkr:http://plnkr.co/edit/BZim5lMhihuyAkDPfzZ6?p=preview與內容投影* ngIf不能正常工作
它CheckBox組件顯示在左邊或右邊的標籤複選框取決於right
屬性。
@Component({
selector: "em-checkbox",
template: `
<div class="form-group">
<div class="checkbox">
<label *ngIf="right">
<input type="checkbox">
<ng-content></ng-content>
</label>
<label *ngIf="!right">
<ng-content></ng-content>
<input type="checkbox">
</label>
</div>
</div>
`
})
export class EmCheckbox {
@Input() right = false;
}
它只適用於第一個ng內容,但不是第二個,我不能把標籤放在右邊。
怎麼樣這種情況下:我有分量「佈局」,如果變量'userLoggedIn == TRUE'我想提出' '如果沒有,我想提出:' ' - 怎麼辦呢? –
好問題,我也有非空元素,我想有條件地顯示每個與內部的投影內容,但它似乎像角不支持此用例 – Ronin