title: Angularjs - set limit on user choice in a select field
body: <p>I'm trying to build a method to limit the user choice in a couple of select fields. Below is a sample and here is a jsfiddle - <a href="http://jsfiddle.net/HB7LU/18414/" rel="nofollow">http://jsfiddle.net/HB7LU/18414/</a></p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div ng-controller="MyCtrl"&gt;
    &lt;select size="5" id="selectpicker1" multiple ng-model="params.monthly" ng-change="selectionChanged(params.monthly)"&gt;
       &lt;option ng-repeat="month in newMonthlyArray"&gt;{{month}}&lt;/option&gt;
    &lt;/select&gt;
  
  &lt;/div&gt; 
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>var myApp = angular.module('myApp', []);
  
  //myApp.directive('myDirective', function() {});
  //myApp.factory('myService', function() {});
  
  function MyCtrl($scope) {
      $scope.name = 'Superhero';
  
      //console.log('YES');
      $scope.newMonthlyArray = ["2015-Jan", "2015-Feb", "2015-Mar", "2015-Apr"];
      $scope.selectionChanged = function (data) {
          if (data.length &gt; 2) {
              alert('You can choose 2 months');
          }
      }
  
  }
  </code></pre>
  
  <p>The part I'm having issues with is to remove the last chosen option and update the <code>$scope</code> variable. I can do with JQuery but didn't want to create a hybrid solution. </p>
  
  <p>Any ideas will be greatly appreciated! </p>