Angularjs,ng-click,如何在MongoDB中放置复选框数组

Angularjs, ng-click, how put array of checkbox in MongoDB

本文关键字:数组 复选框 ng-click Angularjs MongoDB      更新时间:2023-09-26

带有名称和复选框的表单。

我可以将名称放在MongoDB中

,但是如何将复选框的值放在MongoDB中?

索引.html

<tr>
  <td><input class="form-control" ng-model="film.name"></td> 
  <td><label ng-repeat="role in roles">
   <input type="checkbox" checklist-model="user.roles" checklist-value="role"> {{role}}
 </label></td>
  <td><button class="btn btn-primary" ng-click="addFilm()">Add manga</button></td>
</tr>

收藏影片

db.films.insert({aome:" lara croft", gender:['action', 'adventure'] })

功能添加薄膜

$scope.addManga = function() {
       $http.post('/films', $scope.film).success(function(response) {
         })};

$scope.roles = [
    'adventure',
    'action'
  ];
  $scope.user = {
    roles: ['user']
  };

我不知道创建一个函数来接收复选框的值并与名称一起插入。

查看 Angular 文档的输入[复选框],https://docs.angularjs.org/api/ng/input/input[复选框],并特别注意ng-model内容。