jeudi 23 mars 2017

Check angular radio button using jQuery

I have an angular Modal with a pair of radio buttons and depending on the value of 'quicklink' I want a certain button to be checked however neither of the buttons are checked until clicked on with mouse.

Angular Code

<div class="form-group">
                <label>quicklink label</label>
                <label class="radio-inline">
                    <input name="quicklink" rows="3" type="radio" value="1" class="form-control" ng-model="entity.quicklink" id="radio-1"/>
                    yes</label>
                <label class="radio-inline">
                    <input name="quicklink" rows="3" type="radio" value="0" class="form-control" ng-model="entity.quicklink" id="radio-2"/>
                    no</label>
</div>

jQuery

$scope.entity = data;
        if( $scope.entity['quicklink'] == '1'){
            $("#radio-1").prop("checked", true)
        }
        if( $scope.entity['quicklink'] == '0'){
            $("#radio-2").prop("checked", true)
        }

Any help appreciated thanks.




Aucun commentaire:

Enregistrer un commentaire