Angular-ui标记将数组转换为字符串

时间:2016-04-19 11:00:52

标签: javascript angularjs angular-ui tagging

我在模板中使用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"]

0 个答案:

没有答案