Dear All,
I would like to follow up on this. Here's what I have tried so far based on what I searched online. So I created a helper function in the
untyped-item.components.ts.At the top of the file I changed the import into "
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';"
Then I modified the export class into:
export class UntypedItemComponent extends BaseComponent {
@Input() item: Item;
parseUrl(url: string) {
const getHostname = (url) => {
return new URL(url).hostname;
}
}
And then in my untyped-item.components.html, I added this:
<div class="item-page-field" style="margin-bottom: 15px;" *ngFor="let eURL of object.metadata['dc.relation.uri']|keyvalue">
<div class="simple-view-element">
<h2 class="simple-view-element-header" style="font-size: 1.25rem;">Associated URL</h2>
<div class="simple-view-element-body">
<a class="dont-break-out" href="{{eURL.value.value}}" target="_blank">parseUrl({{eURL.value.value}})</a>
</div>
</div>
</div>
It compiled successfully but the resulting display looked like this, it just displayed the function name literally:
If I enclosed the function with {{}} e.g. {{parseUrl({{eURL.value.value}})}}, it failed to compile. This may be a newbie issue but I am struggling with how to call the function that I made to successfully parse the URL so that it will only give me the hostname. In the case on the URL example above, I just want to display the hostname (
onlinelibrary.wiley.com), without the protocol, port number and any subpath. Screenshot from what I want to achieve was posted in my first post above.
Please let me know what I am missing and what to do, since this Angular/Typscript is very new to me.
I appreciate any help you can provide.
euler