title: AngularJS - Check if selected date is equal to next business date
body: <p>I am trying to check if selected date is equal to next business date using AngularJS. If selected date is not equal to the next business date, a warning will be shown, like twitter bootstrap's alert-warning, using ng-show angularjs directive.</p>
  
  <p>Here's the current <a href="http://plnkr.co/edit/Uk8cqQ?p=preview" rel="nofollow"><strong>Fiddle</strong></a> for this.</p>
  
  <p>Currently, the next business day is returned by getNextBusinessDay() $scope function. The comparison is triggered by ng-changed="comparisonResult()" which should return true/false based on comparison, but isn't working.</p>
  
  <p><strong>Here my html code:</strong></p>
  
  <pre><code>&lt;body ng-app="angularjs-starter" ng-controller="MainCtrl"&gt;
  &lt;div class="container"&gt;
    &lt;section id="datepicker"&gt;
      &lt;div class="bs-docs-example"&gt;
        &lt;form class="form-horizontal well"&gt;
          &lt;div class="control-group input-append"&gt;
            &lt;label for="inputDatepicker" class="label" style="margin-right:6px;"&gt;
              Selected Date&lt;/label&gt;
            &lt;input id="inputDatepicker" class="input-small" type="text" 
              ng-model="selectedDate" ng-changed="comparisonResult()" 
              data-date-format="dd/mm/yyyy" bs-datepicker&gt;
            &lt;button type="button" class="btn" data-toggle="datepicker"&gt;
            &lt;i class="icon-calendar"&gt;&lt;/i&gt;&lt;/button&gt;
          &lt;/div&gt;
        &lt;/form&gt;
      &lt;/div&gt;
    &lt;/section&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p><strong>Here's my js code:</strong></p>
  
  <pre><code>var app = angular.module('angularjs-starter', ['$strap.directives']);
  
  app.controller('MainCtrl', function($scope, $window, $location) {
  
    // Datepicker directive
    $scope.selectedDate = null;
  
      $scope.getNextBusinessDay = function() {
          return $scope.getDeliveryDateObj(1);
      }
  
      $scope.getDeliveryDateObj = function(businessDaysLeftForDelivery){
          var now = new Date();
          var dayOfTheWeek = now.getDay();
          var calendarDays = businessDaysLeftForDelivery;
          var deliveryDay = dayOfTheWeek + businessDaysLeftForDelivery;
          if (deliveryDay &gt;= 6) {
              businessDaysLeftForDelivery -= 6 - dayOfTheWeek; // deduct this-week days
              calendarDays += 2; // count this coming weekend
              deliveryWeeks = Math.floor(businessDaysLeftForDelivery / 5); // how many whole weeks?
              calendarDays += deliveryWeeks * 2; // two days per weekend per week
          }
          now.setTime(now.getTime() + calendarDays * 24 * 60 * 60 * 1000);
  
          now.setUTCHours(0);
          now.setUTCMinutes(0);
          now.setUTCSeconds(0);
          now.setUTCMilliseconds(0);
  
          return now;
      }
  
      $scope.getNextBusinessDay();
  
      $scope.comparisonResult = function() {
          if($scope.selectedDate == $scope.getNextBusinessDay()) {
              return false;
          } else {
              return true;
          }
      };
  
  });
  </code></pre>
  
  <p>Any help or suggestion will be appreciated. Thanks in advance. :)</p>