Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
34
rated 0 times [  37] [ 3]  / answers: 1 / hits: 17283  / 9 Years ago, thu, december 17, 2015, 12:00:00

While editing the record the data comes in their respective fields for editing, but the checkbox is not checked if its value is 1.



It should be in checked state if it has 1 and not checked if it has 0 as the datatype of the field is tinyint. I am retrieving the data from JSON array via PHP. I am trying to get value by ng-checked={{rec.isSpecial}} but it is not working.



Here is my HTML:





<div class=form-group>
<div class=col-lg-offset-2 col-lg-10>
<div class=checkbox c-checkbox>
<label>
<input type=checkbox ng-checked={{rec.isSpecial}} ng-model=rec.isSpecial>
<span class=fa fa-check></span>Special
</label>
</div>
</div>
</div>





here is my JS



$scope.rec = $resource('api/AdminArea/category/edit/:id', {
id: id
}).get(function(data) {
$scope.rec = data;
});

More From » php

 Answers
1

Since your data returns numbers and not true or false values you could do like so:



<div class=form-group>
<div class=col-lg-offset-2 col-lg-10>
<div class=checkbox c-checkbox>
<label>
<input type=checkbox ng-checked=rec.isSpecial==1 ng-model=rec.isSpecial>
<span class=fa fa-check></span>Special
</label>
</div>
</div>
</div>


see fiddle for more info


[#64033] Tuesday, December 15, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
erick

Total Points: 588
Total Questions: 92
Total Answers: 100

Location: Bangladesh
Member since Sat, Jan 23, 2021
3 Years ago
;