File
Implements
Index
Properties
|
|
Methods
|
|
Inputs
|
|
data
|
Type : Array<object>
|
|
Methods
ngOnDestroy
|
ngOnDestroy()
|
|
|
Public
unsubscribe
|
Default value : new Subject<void>()
|
|
import {takeUntil} from 'rxjs/operators';
import { Subject } from 'rxjs';
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { ContentBadgeService } from './../../services';
@Component({
selector: 'app-content-badge',
templateUrl: './content-badge.component.html'
})
export class ContentBadgeComponent implements OnInit, OnDestroy {
@Input() data: Array<object>;
public unsubscribe = new Subject<void>();
constructor(public contentBadgeService: ContentBadgeService) { }
ngOnInit() {
this.contentBadgeService.badges.pipe(
takeUntil(this.unsubscribe))
.subscribe((data) => {
if (this.data === undefined) {
this.data = [];
}
this.data.push(data);
});
}
ngOnDestroy() {
this.unsubscribe.next();
this.unsubscribe.complete();
}
}
<div class="ui grid padded" *ngIf="data && data.length > 0">
<div class="twelve wide column p-0">
<div class="mr-8 d-inline-block" *ngFor="let selectedbadge of data">
<img
*ngIf="selectedbadge.badgeClassImage || selectedbadge.name"
class="ui mini image"
src="{{selectedbadge.badgeClassImage ||selectedbadge.image}}"
alt="{{selectedbadge.badgeClassName || selectedbadge.name}}"
matTooltip="{{selectedbadge.badgeClassName || selectedbadge.name | uppercase}}" [matTooltipPosition]="'above'"
/>
</div>
</div>
</div>
Legend
Html element with directive