Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. app.directive('dataFactoryModal', ['$compile', '$timeout', function($compile, $timeout) {
  2. return {
  3. scope: { .... }
  4. link: function (scope, element, attrs) {
  5. var html = '
  6. <input ng-model = "recipients" name = "email" type = "text" placeholder = "Enter email(s)" >
  7. ....
  8. // Modal button section
  9. <button type = "button" class = "btn btn-primary" data-factory = "{{dataFactoryCodes}}" data-recipients = "">Submit</button>
  10. ....
  11. ';
  12. ....
  13. }
  14. }
  15. }
  16.  
  17. <button type = "button" class = "btn btn-primary" data-factory = "123;109;129" data-recipients = "meme@email.com;yayaya@email.com">Submit</button>
  18.  
  19. <button type = "button" class = "btn btn-primary" data-factory = "{{dataFactoryCodes}}" data-recipients = "{{recipients}}">Submit</button>
  20.  
  21. scope.replaceCommas = function(value) {
  22. if (value!==undefined) {
  23. return value.replace(',', ';');
  24. }
  25. }
  26.  
  27. data-list = {{replaceCommas(recipients)}}
  28.  
  29. data-list = "email@email.com;email2@email.com,email3@email.com"
  30.  
  31. scope.$watch('recipients', function(newValue, oldValue) {
  32. scope.email = newValue;
  33.  
  34. // if I did this, this would replace all commas with semicolons on the button attribute AND on the textfield
  35. scope.email = newValue.replace(',', ';');
  36.  
  37. // if I did this, this would just replace only the first comma
  38. scope.emailTags = newValue.replace(',', ';');
  39. }
  40.  
  41. data-list = {{emailTags}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement