Well, come on.
This was the solution I found in relation to what I understood about your problem.
You have a list of professions already populated and from the selections that the user makes in the same you want to save in some type of storage.
Below is the code I made so that all selected professions were stored in a specific list.
angular.module('app', [])
.controller('testCtrl', function($scope, $http) {
$scope.objeto = {
profissoes: [
{
id: 1,
nome: 'prof1',
editando: false,
selecionado: false
},
{
id: 2,
nome: 'prof2',
editando: false,
selecionado: false
}
]
};
$scope.profSelect = new Array();
$scope.mudaLista = function(item){
if(item.selecionado) {
$scope.profSelect.push(item);
} else {
$scope.profSelect.splice(item, 1);
}
};
});
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script></head><body><divng-controller="testCtrl as sic">
<label class="requerido">Profissoes</label>
<ul>
<li ng-repeat="item in objeto.profissoes" ng-class="{'editando':item.editando}">
<input type="checkbox" ng-model="item.selecionado" ng-checked="item.selecionado" ng-change="mudaLista(item)"/>{{item.nome}}
</li>
</ul>
<pre ng-bind="profSelect | json"></pre>
</div>
</body>
As you can see, I have used a ng-change
so that with each change (in this case every check ) the system adds / removes the profession from the specific list for selected items profSelect ).
From there you can store it wherever you want.
I hope I have helped:)