0

I have a problem (possibly a simple one) ..

I have an array with "product" objects, $scope.products .. these products are listed as checkboxes.

Now I have a new array with the "product" objects which are selected "chosen ones", the array is loaded with a async promise ..

Now I need a way to check only the checkboxes with the chosen products..

How to do that .. ;)

$scope.products // array with product objects
$scope.chosenproducts // array with chosen product objects - async

// template
<label ng-repeat="product in products">
       <input type="checkbox"  ng-model="chosenproducts"  ng-true-value="{{product}}" 
              ng-false-value="{}" 
              ng-disabled="case.shared"> 
        {{product.name}}
</label>

this is my badly try .. won't work ..

Alvaro Silvino
  • 9,441
  • 12
  • 52
  • 80
pkdkk
  • 3,905
  • 8
  • 44
  • 69
  • are `$scope.products` and `$scope.chosenproducts` the same model? if yes you can just put `$scope.products = $scope.chosenproducts` after you promise had been returned – CozyAzure Oct 02 '15 at 18:12
  • no .. i need to show all the products, and then only check the products from the chosenproducts array, which are loaded from the server afterwards.. – pkdkk Oct 02 '15 at 18:16
  • Can you show us a sample of how your `products` and `chosenproducts` arrays look like? You could probaly merge the `chosenproducts` with `products` when it is received. – show-me-the-code Oct 02 '15 at 18:20
  • Yes, this is very much possible, however it is very hard to show you how to do it without seeing the structure of the data you are bringing in. Can you please show what the structure of the data in `$scope.products` and `$scope.chosenproducts` looks like? You don't need to show the entire payload, just what the general structure looks like for each. Otherwise trying to tailor an answer for you is really shooting in the dark... – ajmajmajma Oct 02 '15 at 18:38

0 Answers0