(scope, element, attr, ctrl)
| 17163 | } |
| 17164 | |
| 17165 | function checkboxInputType(scope, element, attr, ctrl) { |
| 17166 | var trueValue = attr.ngTrueValue, |
| 17167 | falseValue = attr.ngFalseValue; |
| 17168 | |
| 17169 | if (!isString(trueValue)) trueValue = true; |
| 17170 | if (!isString(falseValue)) falseValue = false; |
| 17171 | |
| 17172 | element.on('click', function() { |
| 17173 | scope.$apply(function() { |
| 17174 | ctrl.$setViewValue(element[0].checked); |
| 17175 | }); |
| 17176 | }); |
| 17177 | |
| 17178 | ctrl.$render = function() { |
| 17179 | element[0].checked = ctrl.$viewValue; |
| 17180 | }; |
| 17181 | |
| 17182 | // Override the standard `$isEmpty` because a value of `false` means empty in a checkbox. |
| 17183 | ctrl.$isEmpty = function(value) { |
| 17184 | return value !== trueValue; |
| 17185 | }; |
| 17186 | |
| 17187 | ctrl.$formatters.push(function(value) { |
| 17188 | return value === trueValue; |
| 17189 | }); |
| 17190 | |
| 17191 | ctrl.$parsers.push(function(value) { |
| 17192 | return value ? trueValue : falseValue; |
| 17193 | }); |
| 17194 | } |
| 17195 | |
| 17196 | |
| 17197 | /** |
nothing calls this directly
no test coverage detected