Я создал настраиваемый шаблон для углового форматирования, используя ui-select для ввода тегов:
formlyConfig.setType({
name: 'ui-tagging',
extends: 'select',
template: '<ui-select multiple tagging="" tagging-label="(\'new\')" ng-model="model[options.key]" theme="bootstrap" ng-required="{{to.required}}" ng-disabled="{{to.disabled}}"> <ui-select-match placeholder="{{to.placeholder}}"> {{$select.selected[to.labelProp || \'name\']}} </ui-select-match> <ui-select-choices repeat="option in to.options | filter: $select.search"> <div ng-bind-html="option | highlight: $select.search"></div> </ui-select-choices> </ui-select>',
});
Вот проблема, я хочу установить функцию для атрибуции тегирования для преобразования тегов, например, в документы ui-select.
<ui-select tagging="tagTransform" .....
Plunker с примером ui-select: http://plnkr.co/edit/m1SQXUxftBLQtitng1f0?p=preview
Чтобы сделать это, вы просто ссылаетесь на функцию в своих настройках поля. Что-то вроде: options.templateOptions.tagTransform
(у которого есть ярлык: to.tagTransform
). Таким образом, у вас может быть что-то вроде:
formlyConfig.setType({
name: 'ui-tagging',
extends: 'select',
template: '<ui-select multiple tagging="to.tagTransform()" tagging-label="(\'new\')" ng-model="model[options.key]" theme="bootstrap" ng-required="{{to.required}}" ng-disabled="{{to.disabled}}"> <ui-select-match placeholder="{{to.placeholder}}"> {{$select.selected[to.labelProp || \'name\']}} </ui-select-match> <ui-select-choices repeat="option in to.options | filter: $select.search"> <div ng-bind-html="option | highlight: $select.search"></div> </ui-select-choices> </ui-select>',
});
И поле config будет выглядеть примерно так:
{
type: 'ui-tagging',
templateOptions: {
tagTransform: function() {}
}
}