Creating a custom widget
See original GitHub issueQuestion received by email:
I have a question regarding the angular2-schema-form repo. You say that it is possible to generate your own widget, sadly I don’t understand how and where I should begin. Could you give me some information or documentation regarding creating your own widget?
You need to derivate the widget you want to customize:
@Component({
selector: 'mdl-sf-string-widget',
templateUrl: './string.widget.html'
})
export class MyStringWidget extends StringWidget {}
You need to provide its html template (let’s imagine we want to use the Material Design text field):
<mdl-textfield [label]="schema.description" type="string" floating-label
[name]="name" [attr.readonly]="schema.readOnly?true:null"
[attr.id]="id"
[attr.disabled]="schema.readOnly?true:null"
[formControl]="control"></mdl-textfield>
And you need to declare it in a custom registry:
import { MyStringWidget } from './mystring';
export class MyWidgetRegistry extends DefaultWidgetRegistry {
constructor() {
super();
this.register('string', MyStringWidget);
}
}
And then you need to provide your registry in your module:
providers: [{provide: WidgetRegistry, useClass: MyWidgetRegistry}],
Note: I will add this to the doc
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:5
Top Results From Across the Web
How to Create Custom Widgets on iPhone - How-To Geek
Now, go to the “My Widgets” tab and tap the “Add (Size) Widget” for the size of the widget you want to create....
Read more >How to Customize Your iPhone With Widgets - HelloTech
To create your own widgets, download the Widgetsmith app. Then open the app, choose a widget size, and then customize it. Next, add...
Read more >Create a custom widget - D2L
Create a custom widget · On the Course Home page, click Course Admin > Widgets > Create Widget. · Enter a name and...
Read more >iOS 14 Homescreen Setup - Tips/Tricks + Favorite ... - YouTube
How to customize your iPhone on #iOS 14 using custom widgets plus sharing a few tips and tricks. This setup is a nice...
Read more >How to Create WordPress Custom Widgets
Create a new class that extends WP_Widget. · Begin with __construct() to determine widget's parameters. · Use widget() to define the appearance of ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, StringWidget can be imported from the angular2-schema-form package (the code is here: https://github.com/makinacorpus/angular2-schema-form/blob/master/src/defaultwidgets/string/string.widget.ts )
Hi @marc101101 , I can see changes in the ui. The widget registration is working perfectly (well… not the binding to the value haha).
I edit the post saying that I can also see the [formControl]=control value changed