Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. app.directive('mdiAttrs', function() {
  2. return {
  3. restrict: 'A',
  4. replace: true,
  5. link: (scope, elem) => {
  6. let attrs = scope.mdiCustomProperties || {};
  7.  
  8. Object.keys(attrs).forEach(attrKey => elem.attr(attrKey, attrs[attrKey]));
  9. }
  10. };
  11. });
  12.  
  13. app.directive('mdiInput', () => {
  14. return {
  15. restrict: 'E',
  16. replace: true,
  17. templateUrl: 'templates/mdi-input.html',
  18. scope: (() => {
  19. const inputScope = angular.copy(directiveScopeModel);
  20.  
  21. inputScope.mdiType = '@?';
  22. inputScope.mdiPlaceholder = '@?';
  23. inputScope.mdiTitle = '@?';
  24.  
  25. return inputScope;
  26. })(),
  27. controller: $scope => {
  28. $scope.isLoading = false;
  29. $scope.mdiType = $scope.mdiType || 'text';
  30. }
  31. }
  32. });
  33.  
  34. <label class="mdi-directive">
  35. <span class="mdi-label">{{mdiLabel}}</span>
  36. <input type="{{mdiType}}"
  37. class="mdi-component"
  38. ng-model="mdiModel"
  39. ng-click="mdiClick(this)"
  40. ng-blur="mdiBlur(this)"
  41. ng-class="{'loading': isLoading}"
  42. ng-disabled="isLoading"
  43. placeholder="{{mdiPlaceholder}}"
  44. ng-required="mdiRequired"
  45. title="{{mdiTitle}}"
  46. mdi-attrs="mdiCustomProperties">
  47. </label>
  48.  
  49. <mdi-input mdi-model="mdiInputModel"
  50. mdi-blur="doRequest"
  51. mdi-label="MDI Input Directive"
  52. mdi-custom-properties="{'ui-mask': '(999) 999-9999'}"
  53. mdi-required="true">
  54. </mdi-input>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement