0

How do I change check status of md-checkbox from Angular material depending on the actual checkbox check status?

Here are my checkboxes. They are inside ng-repeat.

    <input type="checkbox" ng-checked="item.completed" ng-model="toDoItemCheckbox">
    <md-checkbox
      ng-change="toggleToDoItem({{item.createdAt}})" ng-model="toDoItemCheckbox" aria-label="todo-checkbox">
    </md-checkbox>
3
  • can you post what you have tried in your controller? or directive? Commented Mar 31, 2016 at 9:50
  • @inspired here is whole controller for this partial i.imgur.com/5QYXI57.png (had to screenshot it, wouldn't be readable inside a comment) Commented Mar 31, 2016 at 9:55
  • can you post your controller div and your ng-repeat? Commented Mar 31, 2016 at 12:15

2 Answers 2

1

Why do you need a input type check box when you already have a md-checkbox. The checked status of md-checkbox can be changed depending on model.

<section class="white-frame-z1" ng-repeat="todo in todos">
    <md-toolbar>
      <div class="md-toolbar-tools">
        <input type="checkbox" ng-model="todo.status" ng-click="toggleTodo(todo)" />Regular Checkbox
        <md-checkbox ng-model="todo.status">
          {{todo.name}}
        </md-checkbox>
      </div>
    </md-toolbar>
  </section>

Check this Codepen for further details.

Sign up to request clarification or add additional context in comments.

Comments

0

You could do so by simply using ng-modelfor two-way data binding:

<div ng-repeat="item in toDoItems">
    <input type="checkbox" ng-model="item.complete">
    <md-checkbox
      ng-change="toggleToDoItem({{item.createdAt}})" ng-model="item.complete" aria-label="todo-checkbox">
    </md-checkbox>
</div>

See this Code Pen.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.