简体   繁体   中英

uncheck default assign checked value in checkbox angular material

I am bit new angular and trying to show a check box with it's value checked at page load but when I try to uncheck this checkbox after page load then it is not allowing me to do so. I am using angular material in this task.

Following is my current code.

<md-checkbox aria-label="Checkbox 1" class="green"  ng-checked="true">
</md-checkbox>

As per angular documentation the ng-checked value should be an expression which can hold both the true and false value. In your code your have assigned this a direct true value that is why it is not working as expected.

check the below plunker

https://plnkr.co/edit/6zGl5E2mEN0JvGSF4159?p=preview

<md-checkbox class="green" ng-checked="master" ng-click="master=!master">
Checkbox

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM