File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
apps/angular/58-content-projection-condition/src/app Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 1+ import { NgTemplateOutlet } from '@angular/common' ;
12import { ChangeDetectionStrategy , Component , input } from '@angular/core' ;
23
34@Component ( {
45 selector : 'app-card' ,
56 template : `
67 @if (small()) {
7- <ng-content select="[title] " />
8- <ng-content select="[message] " />
8+ <ng-container [ngTemplateOutlet]="titleTmpl " />
9+ <ng-container [ngTemplateOutlet]="bodyTmpl " />
910 } @else {
1011 <div class="p-4">
1112 <div class="text-2xl">
12- <ng-content select="[title] " />
13+ <ng-container [ngTemplateOutlet]="titleTmpl " />
1314 </div>
14- <ng-content select="[message] " />
15+ <ng-container [ngTemplateOutlet]="bodyTmpl " />
1516 </div>
1617 }
18+
19+ <ng-template #titleTmpl>
20+ <ng-content select="[title]" />
21+ </ng-template>
22+
23+ <ng-template #bodyTmpl>
24+ <ng-content select="[message]" />
25+ </ng-template>
1726 ` ,
1827 changeDetection : ChangeDetectionStrategy . OnPush ,
1928 host : {
2029 class : 'p-4 border border-grey rounded-sm flex flex-col w-[200px]' ,
2130 } ,
31+ imports : [ NgTemplateOutlet ] ,
2232} )
2333export class CardComponent {
2434 small = input < boolean > ( false ) ;
You can’t perform that action at this time.
0 commit comments