Avatar ·

How to access a DOM element in an Angular component template?

Hello! I'm new to Angular and TypeScript, and I'm having trouble accessing a DOM element inside a component. I have a simple component that displays a button and a paragraph. I want to change the text in the paragraph and add a CSS class to it when the button is clicked. In regular JavaScript, I would use `document.getElementById('myParagraph')`, but in Angular this doesn't seem to work correctly. Here's my current code: ```typescript // my-component.ts import { Component } from '@angular/core'; @Component({ selector: 'app-my', template: `

Initial text

`, styleUrls: ['./my-component.css'] }) export class MyComponent { changeText() { // Trying to get the element by ID const p