-2

How can I solve a problem of "Cannot set properties of null (setting 'innerHTML')"?

I have an Angular project in which I want to have a unique id for every elements, so I use this code:

Enter image description here

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dorra
  • 11
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Apr 03 '22 at 18:24
  • Please review *[Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/)* (e.g., *"Images should only be used to illustrate problems that* ***can't be made clear in any other way***, *such as to provide screenshots of a user interface.*) and take the appropriate [action](https://stackoverflow.com/posts/71726816/edit). Thanks in advance. – Peter Mortensen Apr 07 '22 at 13:31

1 Answers1

-1

Are you sure idAct is correct? I am not a daily Angular user, but in HTML it’s just id. Try replacing idAct with id.

Also try using the window.onload event:

window.onload = (event)=>{
       document.getElementById("uniqueID").innerHTML = id()
}
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131