AngularJS - Simple Directive Use
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="http://code.angularjs.org/1.0.0/angular-1.0.0.js"></script>
<div ng-app="myApp">
<div ng-controller="Ctrl">
<label>Checkbox:
<input type="checkbox" id="check1" ng-model="active" ng-change="check('check1')">
</label>
</div>
</div>
CSS
.ui-state-highlight { background-color: #EEEEEE; }
JavaScript
var app = angular.module('myApp', []);
app.controller('Ctrl',function($scope){
$scope.active = true;
$scope.check = function(clickedid) {
alert('click');
if (document.getElementById(clickedid).checked === true) {
return false;
} else {
var box= confirm("Are you sure you want to do this?");
if (box===true){ // yes sure
return true;
}
else{ // cancel
document.getElementById(clickedid).checked = true;
}
}
};
});