Javascript 从AngularJs中的下拉列表中选择多个选项

Javascript 从AngularJs中的下拉列表中选择多个选项,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,在我的项目中,我需要从下拉列表中选择多个选项。我的代码如下所示: //Controller $scope.data = [{id: 1, Country: Zambia}, {id: 2, Country: United Kingdom} {id: 3, Country: USA}] $scope.selectedCountry = []; //view <select name="multipleSelect" id="

在我的项目中,我需要从下拉列表中选择多个选项。我的代码如下所示:

//Controller
$scope.data = [{id: 1, Country: Zambia},
              {id: 2, Country: United Kingdom}
              {id: 3, Country: USA}]

$scope.selectedCountry = [];


//view
   <select name="multipleSelect" id="multipleSelect" ng-model=" selectedCountry" multiple
      ng-options="country.country as country.country for country in data"></select>
<h4> {{selectedCountry}}</h4>
这很有效,传递给selectedCountry数组的数据是一个类似{id:1,Country:赞比亚}的对象,但问题是我无法从下拉列表中选择多个选项,我只能选择1个选项。 我做错了什么?实现这一目标的最佳方式是什么?
谢谢

我在您的代码中发现了一些错误:

您的JSON数据无效。JSON字符串值必须为双精度 quote,键{key:value}也一样。数组中的每一项 必须用逗号分隔。 国家/地区名称的正确键是country。 我用的是角度1.4.8。 通过在数据中使用:country.country for country,可以使用较短版本的代码

大概是这样的:

//Controller
$scope.data = [{id: 1, Country: Zambia},
              {id: 2, Country: United Kingdom}
              {id: 3, Country: USA}]

$scope.selectedCountry = [];


//view
   <select name="multipleSelect" id="multipleSelect" ng-model=" selectedCountry" multiple
      ng-options="country.country as country.country for country in data"></select>
<h4> {{selectedCountry}}</h4>
作用{ var app=angular.moduleapp,[]; app.controllercontroller,[$scope, 函数$scope{ $scope.selectedCountry=[]; $scope.data=[{ id:1, 国家:赞比亚 }, { id:2, 国家:联合王国 }, { id:3, 国家:美国 }]; } ]; }; div{ 保证金:2倍; } .大版本{ 边框:实心1px FF0000; } .短版本{ 边框:实心1px 005500; } {{selectedCountry}}