Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!