我在模板中使用ui-select指令,绑定在一个属性设置为字符串的对象上。由于ui-select
会将值Array
保存在属性中,是否可以在模型中自动转换此值,以便在保存时值为字符串?我尝试使用ng-value="model.property.join(',')"
,但它没有效果。
元素的完整代码:
<ui-select multiple tagging tagging-label="false" theme="bootstrap" ng-model="user" ng-value="user.keywords.join(',')">
<ui-select-match placeholder="Keywords">{{$item}}</ui-select-match>
<ui-select-choices repeat="keyword in user.keywords | filter:$select.search">{{keyword}}</ui-select-choices>
<ui-select>
当我保存对象时,它会将关键字发送为:["keyword", "other"]