1
我有一个json对象,通过ng-repeat中的复选框加载。它列出了可能的服务,我试图访问我提交表单时已经检查过的服务。从复选框循环中循环浏览json对象
我加载的复选框通过:
<label style="margin-right:10px" ng-repeat="item in dsServces">
<input
type="checkbox"
name="selectedFruits"
value="{{item.DefaultServiceID}}"
ng-model="expense.dsService[item.DefaultServiceName]"
> {{item.DefaultServiceName}}
</label>
我可以看到费用是由与测试内置:
{{ expense.dsService }}
回报(当一对夫妇被选中)
{"Email":true,"Backups":true}
但我不能解决如何循环,所以它只是说服务的名称,所以我可以添加它们反对客户托梅尔。
在后端我有:
$scope.expense = {
tags: []
};
而且在提交:
angular.forEach($scope.expense, function(item) {
console.log(item);
});
哪个吐出Object {Email: true, Backups: true}
,但我不能工作了有一个循环,它只是返回其任何事物都是真实的。
我的主要目的是让像
angular.forEach(forloop) {
//service.item should be like 'Email' whatever the item.DefaultServiceName is
// the loop should be all items that are checked
addService(service.item);
});
不清楚。创建小提琴,以便人们可以帮助你。 – 2014-11-21 14:01:57