如何在AngularJS中获取多个复选框的值

时间:2013-05-07 09:39:09

标签: angularjs

我必须在AngularJS中检查多个复选框的值。我必须在 Controller.js 中使用该值。我能为此做些什么? 我在ng-model中设置了值,但它给出了null数组。

1 个答案:

答案 0 :(得分:3)

你的模特:

{"cars":
  [
    {"v":"m","n":"Mini","c":false},
    {"v":"c","n":"Corvette","c":true},
    {"v":"b","n":"BMW","c":true},
    {"v":"l","n":"Lamborghini","c":true},
    {"v":"f","n":"Ferrari","c":false}
  ]
}

您只想检查:

$scope.brands = $filter('filter')($scope.viewModel, {c: true});

请参阅http://plnkr.co/edit/PnABre?p=preview