Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
Angular2 Testing Template Driven Forms disabled attribute

I have a template driven form with many inputs like the following

<input type="text" name="data" [(ngModel)]="data" [disabled]="disabled" />

I want to write a test which will ensure that all inputs are disabled when the disabled variable is set to true. Below is my test so far. It works, but there are several "disabled" properties on element and element.nativeElement which remain false. Plus, the rendered view in Chrome when stopped in the debugger doesn't look disabled. Only the "ng-reflect-is-disabled" attribute is actually true.

it("should disable all inputs when disabled is true", () => {
    component.disabled = true;
    fixture.detectChanges();

    inputs = fixture.debugElement.queryAll(By.css('input'));
    inputs.forEach(element => {
        expect(element.attributes["ng-reflect-is-disabled"]).toBe('true');
    });

  });

Is there a better way that I can actually check the disabled state of my input?

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda