From 85a81000c78638774a53f0dbfe87e649433e757b Mon Sep 17 00:00:00 2001 From: Ismael Gomes Date: Wed, 4 Feb 2015 10:29:07 -0200 Subject: [PATCH] adding support to HTML labels --- angular-toggle-switch.js | 6 +++--- angular-toggle-switch.min.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/angular-toggle-switch.js b/angular-toggle-switch.js index 97fb3cd..59b73c5 100644 --- a/angular-toggle-switch.js +++ b/angular-toggle-switch.js @@ -29,9 +29,9 @@ }, template: '', compile: function(element, attrs) { diff --git a/angular-toggle-switch.min.js b/angular-toggle-switch.min.js index 9ad81fe..49123dc 100644 --- a/angular-toggle-switch.min.js +++ b/angular-toggle-switch.min.js @@ -1 +1 @@ -angular.module("toggle-switch",["ng"]).directive("toggleSwitch",function(){return{restrict:"EA",replace:!0,require:"ngModel",scope:{disabled:"@",onLabel:"@",offLabel:"@",knobLabel:"@"},template:'',link:function(scope,element,attrs,ngModelCtrl){attrs.onLabel||(attrs.onLabel="On"),attrs.offLabel||(attrs.offLabel="Off"),attrs.knobLabel||(attrs.knobLabel=" "),attrs.disabled||(attrs.disabled=!1),element.on("click",function(){scope.$apply(scope.toggle)}),ngModelCtrl.$formatters.push(function(modelValue){return modelValue}),ngModelCtrl.$parsers.push(function(viewValue){return viewValue}),ngModelCtrl.$render=function(){scope.model=ngModelCtrl.$viewValue},scope.toggle=function(){scope.disabled||(scope.model=!scope.model,ngModelCtrl.$setViewValue(scope.model))}}}}); \ No newline at end of file +angular.module("toggle-switch",["ng"]).directive("toggleSwitch",function(){return{restrict:"EA",replace:!0,require:"ngModel",scope:{disabled:"@",onLabel:"@",offLabel:"@",knobLabel:"@"},template:'',link:function(scope,element,attrs,ngModelCtrl){attrs.onLabel||(attrs.onLabel="On"),attrs.offLabel||(attrs.offLabel="Off"),attrs.knobLabel||(attrs.knobLabel=" "),attrs.disabled||(attrs.disabled=!1),element.on("click",function(){scope.$apply(scope.toggle)}),ngModelCtrl.$formatters.push(function(modelValue){return modelValue}),ngModelCtrl.$parsers.push(function(viewValue){return viewValue}),ngModelCtrl.$render=function(){scope.model=ngModelCtrl.$viewValue},scope.toggle=function(){scope.disabled||(scope.model=!scope.model,ngModelCtrl.$setViewValue(scope.model))}}}}); \ No newline at end of file