// greeting.component.ts import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-greeting', standalone: true, template: `

{{ message }}

`, }) export class GreetingComponent implements OnInit { message = ''; ngOnInit() { console.log('GreetingComponent ngOnInit ran'); // Simulated initial setup — in a real app this would be a service call. this.message = 'Welcome! Loaded at ' + new Date().toLocaleTimeString(); } } /* Notes: - implements OnInit lets TypeScript verify the method name; a typo like ngOninit would be caught at compile time. - ngOnInit runs once, right after the component is created and its inputs are set — the direct equivalent of React's useEffect(() => {...}, []). */