Skip to content

Instantly share code, notes, and snippets.

@rainerhahnekamp
Created August 15, 2023 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rainerhahnekamp/d102905308c2d374d7b757f1ab26a3e9 to your computer and use it in GitHub Desktop.
Save rainerhahnekamp/d102905308c2d374d7b757f1ab26a3e9 to your computer and use it in GitHub Desktop.
// Example showing property binding for ngComponentOutle
@Component({
template: `<ng-container
*ngComponentOutlet="component; inputs: context"
></ng-container>`,
standalone: true,
imports: [NgComponentOutlet],
})
export class AppComponent {
daylightService = inject(DaylightService);
component = this.daylightService.isDay()
? WelcomeAtDayComponent
: WelcomeAtNightComponent;
context: Record<string, unknown> = {};
constructor() {
const { sunrise, sunset } = this.daylightService.getSunTimes();
this.context = {
username: inject(UserService).username,
sunrise, sunset,
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment