From e06f9f7c7e5cff9c5cbf1c875dcc11e36972a1a0 Mon Sep 17 00:00:00 2001 From: David Haubenstricker Date: Sun, 29 Mar 2015 08:31:26 -0400 Subject: [PATCH] allow spacebar to toggle value allow ng-change to be called make on/off text section optional --- .gitignore | 1 + angular-ui-switch.js | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index a088b6f..294e34a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules bower_components +.idea diff --git a/angular-ui-switch.js b/angular-ui-switch.js index 4108863..c642bc8 100644 --- a/angular-ui-switch.js +++ b/angular-ui-switch.js @@ -9,7 +9,8 @@ angular.module('uiSwitch', []) var html = ''; html += ''+attrs.on+'' : ''; /*switch text on value set by user in directive html markup*/ - html += attrs.off ? ''+attrs.off + '' : ' '; /*switch text off value set by user in directive html markup*/ - html += ''; + if (attrs.on || attrs.off) { + html += ''; /*adding new container for switch text*/ + html += attrs.on ? ''+attrs.on+'' : ''; /*switch text on value set by user in directive html markup*/ + html += attrs.off ? ''+attrs.off + '' : ' '; /*switch text off value set by user in directive html markup*/ + html += ''; + } return html; } }