0
<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>

I am not able to get the selected value from list in angularjs in controller.js Please suggest the code to get the selected array value to push it into new array when submit the page

5
  • what you had tried so far? Commented Dec 2, 2014 at 4:10
  • <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> Commented Dec 2, 2014 at 4:29
  • I am trying to use like this$scope.saveReminder = function () { debugger; var list = []; //var selected = $('#idSelect option:selected'); var selected = document.getElementById('idSelect'); for (var i = 0; i < selected.options.length; i++) { if (selected.options[i].selected == true) { list.push(selected.options[i]); } } or $scope.selectedReminder = $scope.emailReminderList; Commented Dec 2, 2014 at 4:30
  • Please don't post this as a comment, but edit your question and add the information there. Commented Dec 2, 2014 at 6:12
  • don't use document.getElementById in angular use scope to access element... Commented Dec 2, 2014 at 10:50

1 Answer 1

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> 

In Controller

$scope.saveReminder = function() {
    angular.forEach($scope.selectedReminder, function($value, $key) {
        $scope.list.push($value.title);
    });
    console.log($scope.list);
};
Sign up to request clarification or add additional context in comments.

2 Comments

Hi tried to use this but not getting $value on controller
HI plz Post JSon Format

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.