Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import { Component, Input } from '@angular/core'
  2.  
  3. @Component({
  4. selector: 'conditional-link',
  5. template: `
  6. <a href="{{url}}" *ngIf="url?!null||!'':false; else withoutLink" class="it-dev-conditional-link" (click)="this.onClick($event)" target={{target}}>
  7. <ng-container *ngTemplateOutlet="content"></ng-container>
  8. </a>
  9.  
  10. <ng-template #content>
  11. <ng-content></ng-content>
  12. </ng-template>
  13.  
  14. <ng-template #withoutLink>
  15. <div class="it-dev-conditional-link" (click)="this.onClick($event)" >
  16. <ng-container *ngTemplateOutlet="content"></ng-container>
  17. </div>
  18. </ng-template>
  19. `
  20. })
  21.  
  22. export class ConditionalLinkComponent {
  23. @Input('url') url: string;
  24. @Input() onClick: Function;
  25. @Input() target: string;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement