I want to add checked and unchecked attribute to the checkbox which is in a table I tried to using it via jquery in angularjs
$('#chksitecolumn_' + item.Id).attr('checked', true)
Here item.Id
is the id which I am iterating and binding it on ng-model
.
and also tried it using angularjs
var element = angular.element('#chksitecolumn_' + item.Id);
element.attr('checked', 'checked');
but it is not working
Here is my checkbox
<input type="checkbox" class="test" id="chksitecolumn_{{item.Id}}"
ng-model="selected[item.Id]"/>
I am passing an ID as a key using ng-model
I want to know that can we check uncheck checkbox except using ng-model
?
ng-model
?prop('checked', true)
, notattr('checked', true)
orattr('checked', 'checked')
. See "Attributes vs. Properties" in the documentation.