Following is my code for checkbox and directive.
When user click on checkbox i wants to know the current state of checkbox. It is not working now
<input type="checkbox" name="fromExistingOffer" ng-model="formData.fromExistingOffer" toggle-existing-offer>
appModule.directive('toggleExistingOffer', function() {
return function(scope, element) {
element.bind('click', function() {
alert(element.attr('checked')); // help needed here
});
};
});
scope.formData.fromExistingOffer?ng-changeinstead?clickevent on thecheckboxin order to check if thecheckboxis checked or not. Why in the world would you want to create a directive like that? Why don't you just use eitherng-clickorng-change. Then if you wan to know if thecheckboxis checked just use the model:formData.fromExistingOffer.