Angular ng-template用作语法

时间:2019-03-22 12:46:28

标签: angular

将ngIf与星号一起使用时,我们可以执行以下操作:

df %>%
  gather(time, ind, -data) %>%
  mutate(time=gsub("r([0-9])","\\1_",time)) %>%
  separate(time, into = c("time","indName")) %>%
  spread(indName, ind)

    data time height weight
1  Ind_1    1    151     56
2  Ind_1    2    154     57
3  Ind_1    3     NA     56
4  Ind_1    4    153     56
5  Ind_1    5    152     55
6  Ind_2    1    163     76
7  Ind_2    2    164     75
8  Ind_2    3    165     76
9  Ind_2    4    162     73
10 Ind_2    5    161     77
11 Ind_3    1    173     87
12 Ind_3    2     NA     88
13 Ind_3    3     NA     87
14 Ind_3    4    172     85
15 Ind_3    5    171     84
16 Ind_4    1    153     64
17 Ind_4    2    154     66
18 Ind_4    3    152     65
19 Ind_4    4    154     63
20 Ind_4    5    154     65

我们如何使用ng-template做同样的事情?

<ng-container *ngIf="obj | async as result">{{result}}</ng-container>

上面的代码抛出了。

1 个答案:

答案 0 :(得分:4)

是的,您还可以在ng-template中使用以下语法:

dropDownReference.GetComponent<DropDownController>().EnableOption("Option B", false);

<ng-template [ngIf]="obs | async" let-result="ngIf">
   {{result}}
</ng-template>

有关更多详细信息,请参见: