toggleSwitch.js 884 B

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