I am trying to implement metawidget on angular2 using metawidget javascricpt api. Till now I am able to generate UI form using buildWidgets. Now I want to append ng-model to input type for two way data binding, can someone suggest me how I can append attributes on input tag.
Asked
Active
Viewed 115 times
1 Answers
1
Thanks for your interest in Metawidget!
The typical way you would do this is to add a WidgetProcessor to your config. WidgetProcessors act on a widget after it has been built (by the WidgetBuilder) and before it is laid out (by the Layout):
metawidgetConfig = {
appendWidgetProcessors: [ function( widget, elementName, attributes, mw ) {
widget.setAttribute( 'foo', 'bar' );
return widget;
} ]
};
See an example here (albeit for Angular 1): http://blog.kennardconsulting.com/2014/05/angularjs-changing-date-format-of.html

Richard Kennard
- 1,325
- 11
- 20
-
I wish if you could take a look at the dom manipulation in A2, and its restrictions. http://stackoverflow.com/questions/39844318/add-dynamic-attributes-in-angular2 – peaceUser Oct 04 '16 at 06:17
-
Okay, have added a comment there (specifically, about an A2 equivalent to $compile) – Richard Kennard Oct 04 '16 at 21:42