File tree Expand file tree Collapse file tree
apps/angular/57-content-projection-default/src/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,8 +5,13 @@ import { CardComponent } from './card.component';
55 imports : [ CardComponent ] ,
66 selector : 'app-root' ,
77 template : `
8- <app-card title="Titre 1" message="Message1" />
9- <app-card title="Titre 2" />
8+ <app-card>
9+ <div title>Titre 1</div>
10+ <div message>Message1</div>
11+ </app-card>
12+ <app-card>
13+ <div title>Titre 2</div>
14+ </app-card>
1015 ` ,
1116 host : {
1217 class : 'p-4 block flex flex-col gap-1' ,
Original file line number Diff line number Diff line change 1- import { ChangeDetectionStrategy , Component , input } from '@angular/core' ;
1+ import { ChangeDetectionStrategy , Component } from '@angular/core' ;
22
33@Component ( {
44 selector : 'app-card' ,
55 imports : [ ] ,
66 template : `
7- <div>{{ title() }}</div>
8- @if (message()) {
9- <div>{{ message() }}</div>
10- } @else {
7+ <ng-content select="[title]"></ng-content>
8+ <ng-content select="[message]">
119 <div>Aucun message</div>
12- }
10+ </ng-content>
1311 ` ,
1412 changeDetection : ChangeDetectionStrategy . OnPush ,
1513 host : {
1614 class : 'p-4 border border-grey rounded-sm flex flex-col w-[200px]' ,
1715 } ,
1816} )
19- export class CardComponent {
20- title = input . required < string > ( ) ;
21- message = input < string | undefined > ( undefined ) ;
22- }
17+ export class CardComponent { }
You can’t perform that action at this time.
0 commit comments