I have an app that was written in angular and its purpose is to display metadata values of several items coming from a database. My goal is to rewrite the output of one metadatavalue, if it matches a given string (for example: If the metadatavalue matches "CC-BY-ND" it should output a link to the Creative Commons Website instead).
This is my Typescript-File ("metadata-values.component.ts"):
import { Component, Input } from '@angular/core';
import { MetadataValue } from '../../../core/shared/metadata.models';
/**
* This component renders the configured 'values' into the ds-metadata-field-wrapper component.
* It puts the given 'separator' between each two values.
*/
@Component({
selector: 'ds-metadata-values',
styleUrls: ['./metadata-values.component.scss'],
templateUrl: './metadata-values.component.html'
})
export class MetadataValuesComponent {
/**
* The metadata values to display
*/
@Input() mdValues: MetadataValue[];
/**
* The seperator used to split the metadata values (can contain HTML)
*/
@Input() separator: string;
/**
* The label for this iteration of metadata values
*/
@Input() label: string;
}
And this is my html file ("metadata-values.component.html"):
<ds-metadata-field-wrapper [label]="label | translate">
<span class="dont-break-out" *ngFor="let mdValue of mdValues; let last=last;">
{{mdValue.value}}<span *ngIf="!last" [innerHTML]="separator"></span>
</span>
</ds-metadata-field-wrapper>
So basically I want to check if {{mdValue.value}} matches for example "CC-ND-BY" and replace the output with something else. Unfortunately my understanding of Typescript is very limited, so I would very much appreciate some help with my problem. :-( Thanks in advance to anyone reading this!