0
I have a list that when I click on it, I need the display: listview
be exchanged for display: none
.
My list is composed this way:
<li class="sub">
<a class="dropdown-item waves-effect" (click)="verificaPermissao(9, 'confestoque')">
<i class="mr-3 fa fa-archive"></i>Estoque</a>
</li>
In my job verificaPermissão
need to set the display
for none
when click occurs. I tried with nativeElement
:
Constructor:
private el: ElementRef
Typescript:
verificaPermissao(idTela?: number, nomeRota?: string){
let lista = this.el.nativeElement.querySelector(".sub");
lista.classList.remove('display')
}
I also tried to:
const element = document.getElementsByClassName('sub');
this.renderer.setElementAttribute(element, "display", "none");
But I get:
ERROR TypeError: el.setAttribute is not a function at
How can I access the property display
of my sub-class?
You can bind the Hidden attribute by passing true or false:
<li [hidden]="condicao">...</li>
– edson alves