What would be the best way to add some directive, e.g. ng-focus-if conditionally to the form's input element when using angular-formly with custom templates?
I would like to use it like this:
$scope.formFields = [
{
key: 'email',
type: 'input',
templateOptions: {
type: 'email',
placeholder: 'Your E-Mail address',
required: true,
focusIf: 'some-expression' // <--- optional directive configuration here
}
}
];
The idea is to apply the directive only when configuration option is actually provided.
ngModelAttrs. It's a bit complex, but by defining a custom type that has defines that as a defaultOption you can accomplish what you're looking for. Look at the UI Mask example.