forked from muicss/mui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckbox.js
More file actions
49 lines (37 loc) · 1.07 KB
/
checkbox.js
File metadata and controls
49 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* MUI Angular Checkbox Component
* @module angular/checkox
*/
import angular from 'angular';
const moduleName = 'mui.checkbox';
angular.module(moduleName, [])
.directive('muiCheckbox', ['$parse', function() {
return {
restrict: 'AE',
replace: true,
scope: {
label: '@',
name: '@',
value: '@',
ngChecked: '=',
ngDisabled: '=',
ngModel: '='
},
template: function(tElement, tAttrs) {
var isUndef = angular.isUndefined,
html = '';
html += '<div class="mui-checkbox"><label><input type="checkbox" ';
// input attributes
html += 'name={{name}} ';
html += 'value={{value}} ';
html += 'ng-disabled="ngDisabled" ';
// handle ngChecked and ngModel
if (!isUndef(tAttrs.ngChecked)) html += 'ng-checked="ngChecked" ';
if (!isUndef(tAttrs.ngModel)) html += 'ng-model="ngModel" ';
html += '>{{label}}</label></div>';
return html;
}
}
}]);
/** Define module API */
export default moduleName;