How to get all elements by class name in Angular 8 from the typescript file

Discussão em 'Angular' iniciado por Code, Novembro 25, 2024.

  1. Code

    Code Guest

    I try to get all elements by class name from HTML template,in the TS File. This is what i tried so far.



    <div class="form-group" >
    <label class="name" class="col-sm-2 control-label" [attr.for]="'skillName' + i">
    {{ arr}} {{ i }}
    </label>
    </div>

    ngAfterViewInit()
    {
    let el = this.document.getElementsByClassName('name');
    console.log(el)
    console.log("*")
    }

    Continue reading...

Compartilhe esta Página