Guest User

Untitled

a guest
Feb 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. <fa-svg icon-class.bind="iconClass"></fa-svg>
  2.  
  3. import {inject, inlineView, bindable} from 'aurelia-framework';
  4.  
  5. @inject(Element)
  6. @inlineView("<template></template>")
  7. export class FaSvg {
  8. @bindable iconClass;
  9.  
  10. constructor(element) {
  11. this.element = element;
  12. }
  13.  
  14. iconClassChanged(newIcon) {
  15. if (!this.live) return;
  16. this._rebuild(newIcon);
  17. }
  18.  
  19. attached() {
  20. this.live = true;
  21. this._rebuild(this.iconClass);
  22. }
  23.  
  24. detached() {
  25. this.live = false;
  26. }
  27.  
  28. _rebuild(iconClass) {
  29. this.element.innerHTML(iconClass ? `<i class="${iconClass}"></i>` : '');
  30. }
  31. }
Add Comment
Please, Sign In to add comment