您可以在一系列选项中使用ng-repeat ng-model.
DEMO http://plnkr.co/edit/KcUshc74FZL1npZsKbEO?p=preview
HTML
Options
{{option.name}}
save to database
JS
var app = angular.module('plunker',[]);
app.controller('MainCtrl',function($scope) {
$scope.options = [{
name: 'java',value: true,},{
name: 'c#',value: false
},{
name: 'angular',value: true
},{
name: 'r',{
name: 'python',{
name: 'c++',value: true
}];
$scope.save = function() {
var optionsCSV = '';
$scope.options.forEach(function(option) {
if (option.value) {
// If this is not the first item
if (optionsCSV) {
optionsCSV += ','
}
optionsCSV += option.name;
}
})
// Save the csv to your db (replace alert with your code)
alert(optionsCSV);
};
});