checkbox checking based on list

I am using angularjs v0.9 to implement my membership beta system...

Currently, I have two controllers...

var selected = []
function Ctrl1(){
    checkCheckboxesByIds(selected );
    //users will select a list of values from checkboxes..
    $('#renewlist input:checked').each(function() {
    selected.push($(this).attr('value'));
    });    
}

function Ctrl2(){
//call an api function with "selected"
}

however, in the html of Ctrl2, it gives the user a choice to move back to the previous if he or she has selected a checkbox wrongly..

I have googled and found this function

function checkCheckboxesByIds(ids) {
 $.each(ids, function(i, id) {
    $('#member-' + id).attr('checked', 'checked'); 
 });
}

However, this only works 75% of the time. If I repeatedly click back and forward, the checkboxes will sometimes fail to be checked...

Is there anyway I can make it more foolproof??

Thank you in advance.

As mentioned by @wirey

I really should be using .prop('checked', true) to set the checked property.

function checkCheckboxesByIds(ids) {
 $.each(ids, function(i, id) {
    $('#member-' + id).prop('checked',true); 
 });
}

It is still not foolproof because the sixth time I submit and return, the checkboxes will not be checked. But this is good enough for my purpose.

Thank you.