/** * @ngdoc directive * @name ionCheckbox * @module ionic * @restrict E * @codepen hqcju * @description * The checkbox is no different than the HTML checkbox input, except it's styled differently. * * The checkbox behaves like any [AngularJS checkbox](http://docs.angularjs.org/api/ng/input/input[checkbox]). * * @usage * ```html * Checkbox Label * ``` */ /** * @ngdoc demo * @name ionCheckbox#simple * @module checkboxSimple * @javascript * var app = angular.module('checkboxSimple', ['ionic']); * app.controller('CheckboxSimpleCtrl', function($scope) { * $scope.pizza = { * pepperoni: true, * sausage: false, * anchovies: true, * jalapenos: false * }; * * $scope.toppings = function() { * var toppings = Object.keys($scope.pizza).filter(function(flavor) { * return $scope.pizza[flavor]; * }); * if (toppings.length > 1) { * toppings[toppings.length - 1] = 'and ' + toppings[toppings.length - 1]; * } * if (toppings.length > 2) { * return toppings.join(', '); * } else if (toppings.length) { * return toppings.join(' '); * } else { * return 'nothing'; * } * }; * }); * * @html * *

* Checkbox: Simple Usage *

*
* *

Your pizza has {{toppings()}}!

* * Pepperoni? * * * Sausage? * * * Jalapeno? * * * Anchovies? * *
*/ IonicModule .directive('ionCheckbox', function() { return { restrict: 'E', replace: true, require: '?ngModel', transclude: true, template: '', compile: function(element, attr) { var input = element.find('input'); forEach({ 'name': attr.name, 'ng-value': attr.ngValue, 'ng-model': attr.ngModel, 'ng-checked': attr.ngChecked, 'ng-disabled': attr.ngDisabled, 'ng-true-value': attr.ngTrueValue, 'ng-false-value': attr.ngFalseValue, 'ng-change': attr.ngChange }, function(value, name) { if (isDefined(value)) { input.attr(name, value); } }); } }; });