Reputation: 307
When the data arrives directly, the table is filled in, and I cannot tell you that if "A" arrives it is checked and if "D" arrives, no.
re(ref: getrefactormodel, contador:number){
let datos= this.fb.group({
word_to_rename: [ref.word_to_rename, Validators.required],
renowned_word: [ref.renowned_word, Validators.required],
name:[ref.name, Validators.required],
id:[ref.id, Validators.required],
activecheck:[ref.activecheck, Validators.required]
});
this.refactorFormGroupItemsArray.insert(contador,datos);
}
Like there is some way to put in the input that if value is A be checked if it is D no.
<input type="checkbox" formControlName="activecheck" value="D" />
Upvotes: 3
Views: 57
Reputation: 24464
checkbox is true/false value even you have set as string when you change it again the value will be either false or true.
re(ref: getrefactormodel, contador:number){
let datos= this.fb.group({
word_to_rename: [ref.word_to_rename, Validators.required],
renowned_word: [ref.renowned_word, Validators.required],
name:[ref.name, Validators.required],
id:[ref.id, Validators.required],
activecheck:[ref.activecheck == 'D' ? true : false , Validators.required]
});
this.refactorFormGroupItemsArray.insert(contador,datos);
}
some angular component libraries has a components like checkbox the behave the way you want I been use primeng check their component here
Upvotes: 2
Reputation: 33
You can used the [checked] operator which accepts a Boolean. try something like;
<input type="checkbox" [checked]="activecheck == 'A'">
Upvotes: 0