MCPcopy Index your code
hub / github.com/angular/angular / Container

Class Container

packages/core/test/acceptance/authoring/signal_inputs_spec.ts:401–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399 `;
400
401 @Component({
402 selector: 'app-container',
403 encapsulation: ViewEncapsulation.None,
404 template: `
405 <button (click)="toggle()">{{ state() ? 'Leave' : 'Enter' }}</button>
406
407 <ng-template #template>
408 <ng-content></ng-content>
409 </ng-template>
410 `,
411 })
412 class Container {
413 private readonly viewContainerRef = inject(ViewContainerRef);
414
415 protected readonly template = viewChild.required<TemplateRef<any>>('template');
416
417 protected state = signal<boolean>(false);
418
419 protected toggle() {
420 this.state() ? this.destroy() : this.create();
421 }
422
423 protected create() {
424 this.state.set(true);
425 this.viewContainerRef.createEmbeddedView(this.template());
426 }
427
428 protected destroy() {
429 this.state.set(false);
430 this.viewContainerRef.clear();
431 }
432 }
433
434 @Component({
435 selector: 'app-content',

Callers

nothing calls this directly

Calls 4

ComponentInterface · 0.90
injectFunction · 0.90
signalFunction · 0.90
requiredMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…