0

previously i have used Boolean property to make checkbox disabled.

here is what i tried so far.

app.component.ts
---------------
 ReadOnly: boolean;

  ngOnInit() {
    this.ReadOnly = true;
  }

app.component.htmt
------------------
<input type="checkbox" [disabled]="ReadOnly">

{ 
         "id":1,
         "category":"cc",
         "sortOrder":"1",
         "active":"Y",
         "Products":[ 
            { 
               "id":100,
               "backEndName":"DDA",
               "sortOrder":"1",
               "active":"N"
            }
         ]
      }

Now i need to use active condition make field disable. how can i do the same?

1
  • What's the latest snippet? An object? A JSON result? How do you access it from the Angular component? Commented Oct 10, 2019 at 7:22

2 Answers 2

6

Try like this:

<input type="checkbox" [disabled]="item.active == 'N'">
Sign up to request clarification or add additional context in comments.

2 Comments

Congratulation for your understanding skills
Thanks for really quick and easy solution
0
import {Renderer2} from '@angular/core';


constructor( public  htmlManipulator: Renderer2) {}

    radioButton(e) {
    if (e.target.checked) {
      this.htmlManipulator.setProperty(this.emilId.nativeElement, 'disabled', null);
    } else {
      this.htmlManipulator.setProperty(this.emilId.nativeElement, 'disabled', ' ');
      console.log('phone click');
    }

  }


    <input type="radio" value="email" name="group2" (change)="radioButton($event)">Email Id

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.