vendredi 25 mars 2016

Find Checkbox from TD of row table with angularJS (IE vs Chrome)

I am struggling below scenario Table->row->td--> Checkbox with ng-model works fine in Chrome but it does not work in IE.

If I remove ng-model from Checkbox then it works in IE too but I do need ng-model

I do have Chrome version : 49.0.2623.87 IE version : 11.0.20 (KB3058515)

angular.module('myApp', [])
  .controller('ctrl', function($scope) {
    $scope.objList = [{
      description: 'a'
    }, {
      description: 'b'
    }, {
      description: 'c'
    }, {
      description: 'd'
    }];

    $scope.toggleObjSelection = function($event, description) {
      // $event.stopPropagation();
      alert('checkbox clicked');

    }

    $scope.rowClicked = function(obj) {
      alert('row clicked');

      $("table tr").each(function() {

        $(this).find("td:first input[type=checkbox]").attr("checked", true);

      });

    };
  });
<head>
  <script data-require="angular.js@1.4.8" data-semver="1.4.8" src="http://ift.tt/1MGU0lM"></script>
  <script data-require="jquery@1.11.3" data-semver="1.11.3" src="http://ift.tt/1EjeICQ"></script>
  <link rel="stylesheet" href="style.css" />
  <script src="script.js"></script>
</head>

<body>
  <div ng-app="myApp">
    <table ng-controller="ctrl">
      <tbody>
        <tr ng-click="rowClicked(obj)" ng-repeat="obj in objList">
          <td>
            <input type="checkbox" ng-model="selectedObjs" />

          </td>
          <td>
            {{obj.description}}
          </td>

        </tr>
      </tbody>
    </table>
  </div>
</body>

Click on any letter and all checkbox should be checked. (Chrome fine but IE does not work)




Aucun commentaire:

Enregistrer un commentaire