Javascript AngularJS用户发送表单时如何放置数据和id
我想发送我的api日期和新闻ID以及表单中的数据。 这是我的表格:Javascript AngularJS用户发送表单时如何放置数据和id,javascript,angularjs,Javascript,Angularjs,我想发送我的api日期和新闻ID以及表单中的数据。 这是我的表格: <div class="well"> <h4>Leave a Comment:</h4> <form role="form" ng-submit="createComm(newComment)" novalidate> <div class="form-group"> <input type="text" class="form-co
<div class="well">
<h4>Leave a Comment:</h4>
<form role="form" ng-submit="createComm(newComment)" novalidate>
<div class="form-group">
<input type="text" class="form-control" placeholder="Autor" ng-model="newComment.author">
</div>
<div class="form-group">
<textarea class="form-control" ng-model="newComment.comment" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
和服务
service.createComm = function(comm){
return $http.post(getUrl(),comm);
}
如何向该代码中添加以发送数据和新闻ID?我不想将数据和id保留为html输入 您可以在表单提交后,使用
angular.extend创建评论请求发送它:
$scope.createComm = function(comment){
NewsModel.create(angular.extend({}, {data: data, newsId: newsId}, comment)).then(function (result){
initCreateComm();
})
}
$scope.createComm = function(comment){
NewsModel.create(angular.extend({}, {data: data, newsId: newsId}, comment)).then(function (result){
initCreateComm();
})
}