removeAttr does not work with angularjs

I am trying to remove the checked attribute from a set of radio buttons. I am using angularjs but I have tried with jquery and it is the same. Here is my code with angularjs:

 var radioList = angular.element(document.querySelectorAll(".radioButtons"));
        for (var i = 0; i <= radioList.length; i++) {

The error is:

TypeError: radioList[i].removeAttr is not a function

what am I doing wrong?? Thanks in advance.

UPDATE: Angular version: AngularJS v1.5.8

3 answers

  • answered 2017-10-11 10:48 jitender

    Your are performing 1 extra loop your loop condition should be i< instead of i<= should be like

    for (var i = 0; i < radioList.length; i++) {

    Here is working demo

  • answered 2017-10-11 11:00 Panos Kordis

    First things first, angularJS makes use of jQuery internally so you can feel free to work with element selectors as you would do in jQuery. After calling the angular.element function, either you're returned no, one or multiple results you'll be returned a results array. As this array is jQuery-aware, you can call a jQuery function on its reference which will be called for every entry in the returned results array. So simply you can do this instead;


  • answered 2017-10-12 06:43 ABT

    I solved the problem adding a value into my input.

    <input type="radio" name="presetRadio" id="{{}}"
           ng-checked="" />

    Thanks to all!!