How do I bind to list of checkbox values with AngularJS?

前端 未结 29 2327
天涯浪人
天涯浪人 2020-11-22 05:20

I have a few checkboxes:





        
29条回答
  •  被撕碎了的回忆
    2020-11-22 06:03

    Try my baby:

    **

    myApp.filter('inputSelected', function(){
      return function(formData){
        var keyArr = [];
        var word = [];
        Object.keys(formData).forEach(function(key){
        if (formData[key]){
            var keyCap = key.charAt(0).toUpperCase() + key.slice(1);
          for (var char = 0; char

    **

    Then for any ng-model with checkboxes, it will return a string of all the input you selected:


    {{formData.heardAboutItn | inputSelected }} //returns Brother or Sister, Friend or Acquaintance

提交回复
热议问题