AngularJS Example:
by jlmcdonald
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div ng-app>
<div ng-controller="MyCtrl">
<button ng-disabled="model.questions.length > 1">button disabled by expression</button>
<button ng-disabled="checkQuestions()">button disabled by function</button>
<button ng-disabled="beDisabled">button disabled by bound variable</button>
</div>
</div>
JavaScript
function MyCtrl($scope) {
$scope.model = {questions: ["hey","ho"]};
$scope.beDisabled=$scope.model.questions.length > 1;
$scope.checkQuestions=function() {
if ($scope.model.questions.length > 1) {
return true;
}
else {
return false;
}
}
}