toggleSwitch.js 919 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import App from '../../../base'
  2. export default App.directive('toggleSwitch', function () {
  3. return {
  4. restrict: 'E',
  5. scope: {
  6. description: '@',
  7. labelFalse: '@',
  8. labelTrue: '@',
  9. ngModel: '=',
  10. },
  11. template: `\
  12. <fieldset class="toggle-switch">
  13. <legend class="sr-only">{{description}}</legend>
  14. <input
  15. type="radio"
  16. name="toggle-switch-{{$id}}"
  17. class="toggle-switch-input"
  18. id="toggle-switch-false-{{$id}}"
  19. ng-value="false"
  20. ng-model="ngModel"
  21. >
  22. <label for="toggle-switch-false-{{$id}}" class="toggle-switch-label"><span>{{labelFalse}}</span></label>
  23. <input
  24. type="radio"
  25. class="toggle-switch-input"
  26. name="toggle-switch-{{$id}}"
  27. id="toggle-switch-true-{{$id}}"
  28. ng-value="true"
  29. ng-model="ngModel"
  30. >
  31. <label for="toggle-switch-true-{{$id}}" class="toggle-switch-label"><span>{{labelTrue}}</span></label>
  32. </fieldset>\
  33. `,
  34. }
  35. })