I created a collection in mongoDB call Mangas, which has " name, autor, genre and info "
Gender is array.
I have a form that will receive the name values, and autor info, the Checkbox to come as Array filled with values to be entered in the form
Question.
How to make a checkbox that has 2 options ** "Adventure ** and ** Action" ** and enter the mongoDB as array?
Same collection below.
MongoDB Mangas
db.mangas.insert({
nome:'Toriko',
autor:'não sei',
gender:['adventure','action'],
info:'...'
})
Index.html
<tr>
<td><input class="form-control" ng-model="manga.nome"></td>
<td><input class="form-control" ng-model="manga.autor"></td>
<!-- aqui precisa ser a CHECKBOX que irá ter os valores do array e inseridos no GENDER -->
<td><input class="form-control" ng-model="manga.info"></td>
<td><button class="btn btn-primary" ng-click="addManga()">Add manga</button></td>
</tr>
<tr ng-repeat="manga in mangas">
<td>{{manga.nome}}</td>
<td>{{manga.autor}}</td>
<td><!-- aqui vai listar o valor recebido do checkbox --></td>
<td>{{manga.info}}</td>
</tr>
Function addManga
$scope.addManga = function() {
console.log($scope.manga);
$http.post('/mangas', $scope.manga).success(function(response) {
console.log(response);
refresh();
})};
Aucun commentaire:
Enregistrer un commentaire