mardi 2 juin 2015

Why does an Angular model prevent a checkbox from being checked by default?

I'm using Angularjs for a website and I now want to use a checkbox. I first created a checkbox like this:

<input type="checkbox" checked>

I can of course remove and add checked to my liking to have it checked by default or not. I now add a model to it (the model is not defined in the controller yet):

<input type="checkbox" ng-model="settings.mySwitch" checked>

The checkbox still displays, but all of a sudden the checked has no effect at all anymore; the checkbox is always unchecked by default.

Why oh why does the model prevent the checked from having any effect? All tips are welcome!




Aucun commentaire:

Enregistrer un commentaire