我的代码在jsFiddle中,下面是该代码的 c/p。我的问题是当我单击星期一选项时如何获取文本Mon而不是["Mon"] ,以及当我多选星期一和星期四时如何获取Mon、Thu (ofc,你明白了: Tue ,周三,周二,星期三和周六选择时,星期六)。我一定遗漏了一些明显的东西,所以请引导我朝着正确的方向前进。
html:
<div ng-app ng-controller="Controller">
<select multiple="multiple" ng-model="day" ng-options='day.id as day.name for day in days'></select>
{{day}}
</div>
js:
function Controller($scope) {
$scope.days = [
{
name: "Monday",
id: "Mon"
},
{
name: "Tuesday",
id: "Tue"
},
{
name: "Wednesday",
id: "Wed"
},
{
name: "Thursday",
id: "Thu"
},
{
name: "Friday",
id: "Fri"
},
{
name: "Saturday",
id: "Sat"
},
{
name: "Sunday",
id: "Sun"
}
];
}