AngularJS add value of checkboxes to an array

前端 未结 3 798
名媛妹妹
名媛妹妹 2021-02-12 21:29

I have this code:

      
  

        
3条回答
  •  被撕碎了的回忆
    2021-02-12 21:57

    ng-true-value only accepts strings so you'll need to use a workaround. This has been a feature request for some time. In the meantime, you can do this:

    Create an ids object in the controller like:

    $scope.ids = {};
    

    and change ng-model to reference a key in that object. You can use the default true/false checkbox values:

    
    

    Then you can loop over the keys in ids checking for true.

    Here is a fiddle

提交回复
热议问题