forked from obalais/angular-ui-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular-ui-switch.js
More file actions
25 lines (24 loc) · 916 Bytes
/
angular-ui-switch.js
File metadata and controls
25 lines (24 loc) · 916 Bytes
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
angular.module('uiSwitch', [])
.directive('switch', function(){
return {
restrict: 'AE'
, replace: true
, transclude: true
, template: function(element, attrs) {
var html = '';
html += '<span';
html += ' class="switch' + (attrs.class ? ' ' + attrs.class : '') + '"';
html += attrs.ngModel ? ' ng-click="' + (attrs.ngChange ? attrs.ngChange + '(); ' : '') + attrs.ngModel + '=!' + attrs.ngModel + '"' : '';
html += ' ng-class="{ checked:' + attrs.ngModel + ' }"';
html += '>';
html += '<small></small>';
html += '<input type="checkbox"';
html += attrs.id ? ' id="' + attrs.id + '"' : '';
html += attrs.name ? ' name="' + attrs.name + '"' : '';
html += attrs.ngModel ? ' ng-model="' + attrs.ngModel + '"' : '';
html += ' style="display:none" />';
html += '</span>';
return html;
}
}
});