Skip to content

Instantly share code, notes, and snippets.

@zdavis
Last active August 29, 2015 14:05
Show Gist options
  • Save zdavis/241149c4a89e4f0cb1fe to your computer and use it in GitHub Desktop.
Save zdavis/241149c4a89e4f0cb1fe to your computer and use it in GitHub Desktop.
# <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