angularjs列表框值选择

时间:2014-12-02 04:05:59

标签: angularjs

<select multiple ng-multiple="true" class="form-control 
   emailReminder width-169" ng-if="checked" ng-model="selectedReminder" 
   ng-options="x as x.title for x in emailReminderList" value="{{x.id}}">
 </select>

我无法从controller.js中angularjs的列表中获取所选值 请提交代码以获取所选数组值,以便在提交页面时将其推送到新数组

1 个答案:

答案 0 :(得分:1)

HTML

<select multiple="multiple" id="idSelect" class="form-control emailReminder width-169" 
  ng-if="checked" ng-model="selectedReminder" 
  ng-options="x as x.title for x in emailReminderList"> 
</select> 

在控制器

$scope.saveReminder = function() {
    angular.forEach($scope.selectedReminder, function($value, $key) {
        $scope.list.push($value.title);
    });
    console.log($scope.list);
};