So I have a directive that has a checkbox in it. I need to make a web service call when the value of the checkbox is changed. How can I get the value of that checkbox when it is clicked? I want the checkbox confined to the scope of the directive.
myModule.directive('test', function() {
return {
restrict: 'A',
replace: true,
scope:{},
template:
'<div>'+
'<input type="checkbox" ng-click="toggleRoomLock()" name="lockRoom" value="lock" ng-model="lockRoom">'+
'</div>',
link: function(scope, element, attrs) {
scope.toggleRoomLock = function(){
//GET VALUE OF CHECKBOX HERE
};
}
}
}
I have tried getting the value using scope.lockRoom but I am getting undefined. Any suggestions?