Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, Input } from '@angular/core'
- @Component({
- selector: 'conditional-link',
- template: `
- <a href="{{url}}" *ngIf="url?!null||!'':false; else withoutLink" class="it-dev-conditional-link" (click)="this.onClick($event)" target={{target}}>
- <ng-container *ngTemplateOutlet="content"></ng-container>
- </a>
- <ng-template #content>
- <ng-content></ng-content>
- </ng-template>
- <ng-template #withoutLink>
- <div class="it-dev-conditional-link" (click)="this.onClick($event)" >
- <ng-container *ngTemplateOutlet="content"></ng-container>
- </div>
- </ng-template>
- `
- })
- export class ConditionalLinkComponent {
- @Input('url') url: string;
- @Input() onClick: Function;
- @Input() target: string;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement