mardi 6 juin 2017

If checkboxes are checked angularjs using ng-repeat

Here is my HTML

    <div ng-controller="Orders">
        <div ng-repeat="order in orders">
          <form>
            <div ng-repeat="item in order.line_items">
                <input type="checkbox" name="order__items[]"?> 
            </div>
          </form>
        </div>
    </div>

Here is my Controller:

app.controller("Orders", function($scope, WC) {
    var Woocommerce = WC.WC();
    // get orders from json
    Woocommerce.get('orders?filter[post_status]=wc-processing&?filter[limit]=-1', function(err, data, res){
        var obj = JSON.parse(res);
        console.log(obj.orders);
        $scope.orders = obj.orders;
        $scope.$apply()
    });

});`

It outputs this:

enter image description here

Per order I want to know true false if any of the order items has been checked so I can then show a submit button.

On the checkboxes I have tried ng-repeat and ng-model with no success so far.




Aucun commentaire:

Enregistrer un commentaire