Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to display a hyperelink #2709

Closed
Rossco8 opened this issue Feb 19, 2021 · 2 comments
Closed

How to display a hyperelink #2709

Rossco8 opened this issue Feb 19, 2021 · 2 comments
Labels

Comments

@Rossco8
Copy link

Rossco8 commented Feb 19, 2021

Question
How to display a simple HTML hyperlink in a form?

This is my custom type

import { Component } from '@angular/core';
import { FieldType } from '@ngx-formly/core';

@Component({
 selector: 'formly-link-component',
 template: `
 <a [href]="to.url">{{ to.title }}</a>
 `,
})
export class FormlyLinkComponent extends FieldType {

}

In app.module.ts I have added

{ name: "link", component: FormlyLinkComponent },

Here is a stackblitz example. The link component is always ignored when loading from JSON
https://stackblitz.com/edit/ngx-formly-ui-material-fv4a2x?file=src/assets/simple.json

@aitboudad
Copy link
Member

use widget:

{
  "type": "string",
+ "widget": {
+   "formlyConfig": {
+     "type": "link",
+     "templateOptions": { "url": "https:\/\/en.wikipedia.org\/wiki\/Chuck_Norris" }
+   }
+ }
}

#1982 (comment)

@Rossco8
Copy link
Author

Rossco8 commented Feb 19, 2021

thanks, that worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants