Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda