JSFiddle - React, Tailwind, and code Playground

by Sajeetharan Sinnathurai

HTML

<div ng-controller="MyCtrl">
  <button ng-click="checkSelectedDays()">
    Check selected days
  </button>

  <div ng-repeat="day in days">
    <label>
      <input type="checkbox" ng-true-value="'{{day.display}}'" ng-false-value="''" ng-model="selectedDays[$index]" ng-change="selectDay(day)"> {{day.display}}
    </label>
  </div>

  <br>

 
</div>

JavaScript

var myApp = angular.module('myApp', []);

myApp.controller('MyCtrl', function($scope) {
  $scope.selectedDays = []; 
  $scope.days = [{
    display: "weekdays",
    actual: "weekdays"
  }, {

    display: "weekends",
    actual: "weekends"
  }, {

    display: "Mondays",
    actual: "1"
  }, {

    display: "Tuesdays",
    actual: "2"
  }, {

    display: "Wednesdays",
    actual: "3"
  }, {

    display: "Thursdays",
    actual: "4"
  }, {

    display: "Fridays",
    actual: "5"
  }, {
    display: "Saturdays",
    actual: "6"
  }, {
    display: "Sundays",
    actual: "7"
  }];
  
   $scope.selectDay = function(selectedDay) {
    $scope.selectedDays.push(selectedDay);
  }
  
  
  $scope.checkSelectedDays = function() {
    var modelNames = [];
    debugger;
    var aletrMsg = '';
    angular.forEach($scope.selectedDays, function(day) {       
        modelNames.push(day);     
        console.log(modelNames);
    });
   
  }
  
  
  
});