ReferenceError: alert is not defined

Discussão em 'Angular' iniciado por phos, Janeiro 7, 2025.

  1. phos

    phos Guest

    when I try to execute my function showWelcomeMessage() via the constructor, I get the error ReferenceError: alert is not defined. What could be the issue ? Im using Angular 19 in VS Code.

    @Component({
    selector: 'app-data-binding',
    imports: [],
    templateUrl: './data-binding.component.html',
    styleUrl: './data-binding.component.css'
    })
    export class DataBindingComponent {

    firstName: string = "Lulu";
    rollNo: number = 121;
    isActive: boolean = true;
    currentDate: Date = new Date();
    myPlaceholder: string = "Enter your name"
    divBlue: string = "bg-primary";

    constructor() {
    console.log(this.firstName)
    this.isActive = false;
    console.log(this.isActive)

    this.showWelcomeMessage() // <------- problem

    }

    showWelcomeMessage () {
    alert("Welcome")
    }

    }

    Continue reading...

Compartilhe esta Página