Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { ChangeDetectionStrategy, Component, model } from '@angular/core';

@Component({
selector: 'app-expandable-card',
Expand Down Expand Up @@ -50,5 +50,5 @@ import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
},
})
export class ExpandableCard {
public isExpanded = signal(false);
public isExpanded = model(false);
}
13 changes: 9 additions & 4 deletions apps/angular/59-content-projection-defer/src/app/page-2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ChangeDetectionStrategy,
Component,
ResourceStatus,
signal,
} from '@angular/core';
import { ExpandableCard } from './expandable-card';

Expand All @@ -17,7 +18,7 @@ interface Post {
selector: 'app-page-2',
template: `
page2
<app-expandable-card>
<app-expandable-card [(isExpanded)]="isCardExpanded">
<div title>Load Post</div>
<div>
@if (postResource.isLoading()) {
Expand All @@ -36,8 +37,12 @@ interface Post {
imports: [ExpandableCard],
})
export class Page2 {
public postResource = httpResource<Post[]>(
'https://jsonplaceholder.typicode.com/posts',
);
public postResource = httpResource<Post[]>(() => {
return this.isCardExpanded()
? 'https://jsonplaceholder.typicode.com/posts'
: undefined;
});
protected readonly ResourceStatus = ResourceStatus;

isCardExpanded = signal(false);
}
Loading