max7
max7

Reputation: 798

setting checkbox to check Angular JS

I have the following code:

<input type="checkbox" data-col="1" name="eighth-slot" data-ng-model="scope.friends.calendar[0][8]" class="ng-pristine ng-valid">

the first [0] is the day of the week and the second [8] indicates a 2hr time slot and returns true/false indicating if they are free on that day during that particular time slot.

I figure binding the model to the input is the first thing but how do I make it checked if the the last parameter is true?

Upvotes: 1

Views: 2259

Answers (1)

Tosh
Tosh

Reputation: 36030

You do not need to say scope.friends.calendar[0][8] as scope is assumed to be receiver in the template. so just friends.calendar[0][8] is fine.

function Ctrl($scope) {
  $scope.friends = {calendar: [[]]};
  $scope.friends.calendar[0][8] = true;
}

for instance, would make the checkbox checked.

Upvotes: 3

Related Questions