document.getElementById returns null

Hello, I am trying to unhide an ion-input with document.getElementById but it returns null did i forget something? Also maybe someone could provide a code with Angular, thanks for any help!

My code:

HTML:

ion-input label=“Mitarbeiter” label-placement=“floating” fill=“outline” placeholder=“Mitarbeiter” id=“mitarbeiter” style=“display: none;”>

TS:

addMitarbeiter(){
document.getElementById(“mitarbeiter”).style.display = “block”;
}

Two things:

  1. Nice Denglish :crazy_face:
  2. That’s not how you do stuff like this in angular. Have a look at ngStyle or ngClass

I solved it with Angular.

i used this example code.

<label *ngIf="isVisible"></label>
export class YourComponent {
  isVisible = false;
  
  // You can set isVisible to true to show the label
  showLabel() {
    this.isVisible = true;
  }

  // You can set isVisible to false to hide the label
  hideLabel() {
    this.isVisible = false;
  }
}