我有一个角度形式的多选字段:
<div crm-ui-field="{name: 'subform.committees', title: ts('Secondary Committee')}">
<div ng-controller="CommitteeCtrl">
<select
multiple="multiple"
crm-ui-id="subform.committees"
name="secondary_committee"
crm-ui-select="{dropdownAutoWidth : true, allowClear: false, placeholder: ts('Choose Committee')}"
ng-model="mailing.secondary_committee"
ng-options="comm as comm.label for comm in comms track by comm.value"
>
<option />
</select>
</div>
</div>
我遇到了一些问题,试图弄清楚如何存储数据并检索数据,以便角度形式正确加载值。角度有望看到数据吗?
答案 0 :(得分:1)
对于MultiSelect ng-model是"auth0-lock": "^10.11.0",
"angular-lock": "^1.0.5",
"auth0.js": "7.6.1"
,
发送到后端时你需要将[]作为字符串,然后它将适合DB中的一列:
Array
因此,在检索时,您需要将模型数据设置为选定实体的数组,然后angular将自动填充选择实体的var secondaryCommitteeStr = $scope.mailing.secondary_committee.join(',');
。
$scope.mailing.secondary_committee