samedi 11 mars 2017

Angularjs - Dynamic Checkboxes to hide/show Divs

I am new to front-end web development. I am creating checkboxes dynamically using Angularjs.

<div ng-repeat="x in Brands" style="margin-left: 20px">
   <input type="checkbox" ng-model="newObject[x.product_brand]">
   <label>  </label>
</div>

Following the methods given on the links below, I wanted to hide/show divs using using the dynamically created checkboxes.

  1. Dynamic ng-model
  2. ng-show

Here's the code-

<div class="item panel panel-default" ng-repeat="x in Brands" ng-show="newObject[x.product_brand]">
    <div class="panel-heading">
        
    </div>
    <div class="panel-body">
    </div>
</div>

Controller-

app.controller('BrandController', function($scope, $http) {
    getProductsInfo();

    function getProductsInfo() {
        $http.get("sql.php").success(function(data) {
            $scope.Brands = data;
        });
    };

});

But it is not working. Checking/Unchecking the checkboxes does nothing.




Aucun commentaire:

Enregistrer un commentaire