R.co
R.co

Reputation: 77

Check the checkbox by default

My code :

<label ng-class="[getClasscolor(0)]"><input class="opened" ng-checked="getStatut(data.statut_cas_id_statut1, 0)" ng-model="data.statut_cas_id_statut1" value="0" type="checkbox">&nbsp;Open&nbsp;</label>

I would check this checkbox by default and call the function getStatut by default. How can I do that ? I'm starting with angularjs

Upvotes: 1

Views: 38

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172428

You can try like this:

<div ng-app="">
<input type="checkbox" ng-model="checked" ng-init="checked=true">
</div>

JSFIDDLE DEMO

You can try to use ng-change="!key || getStatut(data.statut_cas_id_statut1, 0)"

So it would be like

<div ng-app="">
<input type="checkbox" ng-model="checked" ng-init="checked=true" 
     ng-change="!key || getStatut(data.statut_cas_id_statut1, 0)">
</div>

Upvotes: 1

Related Questions