我使用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" .....
使用ui-select示例的Plunker:http://plnkr.co/edit/m1SQXUxftBLQtitng1f0?p=preview
答案 0 :(得分:1)
为此,您只需在字段选项中引用一个函数即可。类似于: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>',
});
字段配置类似于:
{
type: 'ui-tagging',
templateOptions: {
tagTransform: function() {}
}
}