MCPcopy Create free account
hub / github.com/binux/qiandao / checkboxInputType

Function checkboxInputType

web/static/components/angularjs/angular.js:17165–17194  ·  view source on GitHub ↗
(scope, element, attr, ctrl)

Source from the content-addressed store, hash-verified

17163}
17164
17165function 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/**

Callers

nothing calls this directly

Calls 1

isStringFunction · 0.70

Tested by

no test coverage detected