I have an array which is displayed as a checklist. Based on the user selection, I want to store the names of the checklist as an array in a second object. However I cannot figure out, how to only store the names
here is the HTML:
<div ng-app="editorApp" ng-controller="editController">
<pre> {{ comm.mysites | json }}</pre>
<div class="checkbox" ng-repeat="mysite in mysites">
<label>
<input type="checkbox" ng-model="comm.mysites[mysite]" ng-true-value=" true" ng-false-value="false" />
{{ mysite }}
</label>
</div>
The JS:
var editorApp = angular.module('editorApp',[]);
editorApp.controller('editController', function($scope) {
$scope.mysites = ['customer solutions', 'originations', 'back office', 'branch network', 'collections', 'insurance'];
$scope.comm = {
title: 'test title',
content: 'test content',
'mysites': {}
};
});
Expected Result that I am looking:
$scope.comm = {
title: 'test title',
content: 'test content',
'mysites': {'customer solutions', 'originations', 'insurance'}
};
Thanks in advance. Here is the JSFiddle: http://jsfiddle.net/_fhdamd/6aqpok91/