Last active
August 29, 2015 14:05
-
-
Save zdavis/241149c4a89e4f0cb1fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# <mng-switcher type="checkbox" ng-model="account.is_individual" /> | |
app.directive('mngSwitcher', [() -> | |
new class mngSwitcher | |
restrict: 'EA' | |
scope: { | |
ngModel: '=' | |
} | |
template: ' | |
<div ng-class="{checked: ngModel == true}" class="switcher checked"> | |
<div class="switcher-toggler"></div> | |
<div class="switcher-inner"> | |
<div ng-click="toggle()" class="switcher-state-on">ON</div> | |
<div ng-click="toggle()" class="switcher-state-off">OFF</div> | |
</div> | |
</div> | |
' | |
link: ($scope, element, attr) -> | |
$scope.toggle = () -> | |
if $scope.ngModel == true | |
$scope.ngModel = false | |
else | |
$scope.ngModel = true | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment