This is my html
<div ng-repeat=" month in months track by $index" ng-hide="fromdate == '' || todate =='' ||option != 'Yearly'">
<input class="toBeChecked" type="checkbox" ng-disabled="month.disabled" checker-directive>
<label ng-bind="month.Name"></label>
</div>
This is my controller
$scope.months = [
{ "disabled": "false", "Name": "January" },
{ "disabled": "false", "Name": "February" },
{ "disabled": "false", "Name": "March" },
{ "disabled": "false", "Name": "April" },
{ "disabled": "false", "Name": "May" },
{ "disabled": "false", "Name": "June" },
{ "disabled": "false", "Name": "July" },
{ "disabled": "false", "Name": "August" },
{ "disabled": "false", "Name": "September" },
{ "disabled": "false", "Name": "October" },
{ "disabled": "false", "Name": "November" },
{ "disabled": "false", "Name": "December" },
]
This is my directive
app.directive('monthDirective', function () {
return {
restrict: 'A',
link: function (scope, elem) {
var fromDate , toDate;
scope.$watch('fromdate', function (newValue, oldValue) {
fromDate = new Date(newValue);
fromDate = moment(newValue, 'YYYY-MM-DD');
console.log('newValue', newValue)
});
scope.$watch('todate', function (newValue, oldValue) {
toDate = new Date(newValue);
toDate = moment(newValue, 'YYYY-MM-DD');
var range = moment.range(fromDate, toDate);
range.by('months', function (moment) {
var monthArray = moment.toArray('months');
for (var i = 0; i <= scope.months.length; i++)
{
var status = false;
if (i == monthArray[1]) {
status = true;
}
if(status)
{
// $('.toBeChecked').prop('disabled', false);
console.log('TrueStatus', scope.months.disabled)
scope.months.disabled = 'false'
}
else
{
//$('.toBeChecked').prop('disabled', true);
console.log('FalseStatus', scope.months.disabled)
scope.months.disabled = 'true'
}
}
});
});
}
}
})
I want to send the value of "scope.months.disabled" from the directive to the front end "ng-disabled="month.disabled"" and disable the checkboxes as per the logic