My view:
<div ng-app="Motorista" ng-controller="motoristaController as vm">
<fieldset>
<legend> Categoria CNH </legend>
<input type="checkbox" ng-model="vm.motorista.categoria_cnh.value1" />A
</br>
<input type="checkbox" ng-model="vm.motorista.categoria_cnh.value2" />B
</br>
<input type="checkbox" ng-model="vm.motorista.categoria_cnh.value3" />C
</br>
<input type="checkbox" ng-model="vm.motorista.categoria_cnh.value4" />D
</br>
<input type="checkbox" ng-model="vm.motorista.categoria_cnh.value5" />E
</br>
</fieldset>
<input type="button" ng-click="vm.inserir()" value="Inserir"/>
</div>
My controller:
var linkservice = "http://localhost:8080/Cast_Frotas/rest/motorista/";
var app = angular.module('Motorista',[]);
app.controller('motoristaController', function ($scope, $http) {
//vm.inserir = inserir;
iniciar();
function iniciar() {
this.motorista = {};
this.motorista.categoria_cnh = {
value1 : true,
value2 : true,
value3 : true,
value4 : true,
value5 : true
};
}
//PEGANDO ITENS DA SESSION STORAGE
/*var motorista = window.localStorage.getItem('motorista');
$scope.motorista = JSON.parse(motorista);*/
$http.get(linkservice + "select").then(function (response) {
$scope.registros = response.data;
});
$http.get(linkservice + "selectPrestador").then(function (response) {
$scope.prestadores = response.data;
});
$http.get(linkservice + "selectCurso").then(function (response) {
$scope.cursos = response.data;
});
$scope.inserir = function (){
alert(this.motorista.categoria_cnh);
$scope.jsonObj = angular.toJson($scope.motorista, false);
}
});