javascript - Angular-formly: Why does the directive behave differently from the type? -


i have 2 input fields, both generated same template. on both setting

...     templateoptions: {   ...   required: true } 

one input field registered using formlyconfig.settype other using directive. have created js bin here.

only first getting required attribute, second not. in docs custom templates (controller option) says:

provides ability add custom behavior type without having make entire directive (you can make directive instead if wish).

what doing wrong?

the problem in second example when angular-formly processing options template, angular-formly sees is: <plain-text> template. hence, doesn't know element place required attribute on. angular-formly attach attributes these elements have ng-model on them because elements attribute makes sense.

again, key here angular-formly sees when it's processing template (before it's compiled). doesn't matter directive compiles to. yes, can use own directive, if want leverage features of angular-formly, needs utilize ng-model controller (like directive used in this example).

good luck!


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -