【发布时间】:2015-10-26 23:11:14
【问题描述】:
我正在尝试编写一个自定义的正式模板来使用 ng-tags-input:
angular.module('myMod').run(function(formlyConfig) {
formlyConfig.setType({
name:'tag',
template:"<label class='control-label' ng-if='to.label'>{{to.label}}</label>" +
"<tags-input ng-model='model[options.key]' ng-attr-placeholder='{{to.placeholder}}'>" +
"<auto-complete source='{{to.tags}}'></auto-complete></tags-input>"
^^^^^^^^^^^^^^^^^^^
});
})
其中to.tags指的是formly模板的templateOptions:
templateOptions: {
tags: 'dataModel.getProductTags()'
在这种情况下使用双括号会导致 $parse 错误。我怎样才能从to.tags的内容中间接填充那个source属性?
我也试过ng-attr-source='to.tags',但没有成功。
我怀疑我只是没有想到一些显而易见的事情。如果简单且明智,请附上相关参考资料。
【问题讨论】:
标签: angularjs ng-tags-input angular-formly