mercredi 2 décembre 2015

Disabling the checkbox in angular directive template

I have the directive shown below that displays a checkbox in cells of a table:

app.directive('csSelect', function () {
    return {
        template: '<input ng-model="checked" ng-click="csFunc()" disabled="isDisabled" type="checkbox"/>',
        scope: {
            row: '=csSelect',
            csFunc: '&csFunc',
            isDisabled: '=csDisabled'
        },
        link: function (scope, element, attr, ctrl) {

            scope.$watch('checked', function (newValue, oldValue) {
                if (newValue === true) {
                    element.parent().addClass('st-selected');
                } else {
                    element.parent().removeClass('st-selected');
                }
            });
        }
    };
});


<td  cs-select="device" cs-func='selectRow(device.ItsRepairImeiListId)' cs-disabled="false" ></td>


The problem is that the disabled attribute is not working for some reason. Whatever value I provide, the checkbox is always disabled. I have tried using @csDisabled as well but no success.

Any ideas on what I should do get the checkbox disabled whenever I want ?




Aucun commentaire:

Enregistrer un commentaire