MCPcopy Create free account
hub / github.com/angular/angular / ComponentWithHooks

Class ComponentWithHooks

packages/core/test/acceptance/view_container_ref_spec.ts:2413–2454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2411 const log: string[] = [];
2412
2413 @Component({
2414 selector: 'hooks',
2415 template: `{{ name }}`,
2416 standalone: false,
2417
2418 changeDetection: ChangeDetectionStrategy.Eager,
2419 })
2420 class ComponentWithHooks {
2421 @Input() name: string | undefined;
2422
2423 private log(msg: string) {
2424 log.push(msg);
2425 }
2426
2427 ngOnChanges() {
2428 this.log('onChanges-' + this.name);
2429 }
2430 ngOnInit() {
2431 this.log('onInit-' + this.name);
2432 }
2433 ngDoCheck() {
2434 this.log('doCheck-' + this.name);
2435 }
2436
2437 ngAfterContentInit() {
2438 this.log('afterContentInit-' + this.name);
2439 }
2440 ngAfterContentChecked() {
2441 this.log('afterContentChecked-' + this.name);
2442 }
2443
2444 ngAfterViewInit() {
2445 this.log('afterViewInit-' + this.name);
2446 }
2447 ngAfterViewChecked() {
2448 this.log('afterViewChecked-' + this.name);
2449 }
2450
2451 ngOnDestroy() {
2452 this.log('onDestroy-' + this.name);
2453 }
2454 }
2455
2456 it('should call all hooks in correct order when creating with createEmbeddedView', () => {
2457 @Component({

Callers

nothing calls this directly

Calls 2

ComponentInterface · 0.90
InputInterface · 0.90

Tested by

no test coverage detected