【发布时间】:2016-11-12 18:36:25
【问题描述】:
我正在尝试使用此angular bootstrap feedback form 收集用户反馈数据并将信息索引到 Elasticsearch(使其可搜索)。
所以在我的 Elasticsearch 的 searchService 中,我只是这样做了:
this.userSearchFeedback = function (userFeedbackForm) {
esClient.index({
index: 'searchfeedback-index1',
type: 'general',
opType: 'index',
refresh: true,
body: {
fields: ['comments', 'email']
}
}).then(function(es_return) {
console.log('success');
}, function(error) {
console.log('error');
});
};
userFeedbackForm 是表单的名称,如下所示:
<div class="row">
<div class="col-xs-12">
<div class="alert alert-info" role="alert">
We would love to hear your thoughts and suggestions on what we get right and wrong - it helps us improve our services to you. Your feedback is appreciated and helps us get better!
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<!-- DESCRIPTION -->
<div class="form-group">
<pre>Model: {{comments | json}}</pre>
<label for="description_field" class="control-label">Comment:</label>
<textarea class="form-control" placeholder="Please describe your issue or share your feedback!" name="comments" ng-model="comments" style="min-height: 165px;"></textarea>
</div>
<!-- /DESCRIPTION -->
<!-- EMAIL -->
<div class="form-group">
<pre>Model: {{email | json}}</pre>
<label for="email_field" class="control-label">Email:</label>
<input type="text" class="form-control" placeholder="Email" name="email" ng-model="email" />
</div>
<!-- /EMAIL -->
</div>
我已经为这两个输入添加了 ng-models 并将它们添加到我的控制器中
//initialize feedback form
$scope.feedback = {
comments: '',
email: ''
};
该模块已经带有一个函数,该函数通过 ng-click 表单模板调用...
function submitButtonPressed(form) {
console.log("Submit button pressed");
console.log(form);
console.log($scope.feedback.comments);//added
console.log($scope.feedback.email);//added
这就是我卡住的地方。
我还需要对该函数做些什么,以便它在我的 searchService 中调用 userSearchFeedback() 以便可以将表单数据索引到 ES?
【问题讨论】:
-
您尚未定义具体问题或向我们展示minimal reproducible example 中的所有相关代码。显示的表单甚至没有任何表单控件。这里需要更多细节
-
@charlietfl 你的权利 - 我今天太着急了,我把这个扔了。我现在正在查看代码并意识到缺少的所有内容。一旦我得到他的处理,我会回帖以便其他人可以受益(如果他们需要的话)。
-
如果具体问题未知且未提供与该问题相关的代码,则没有人可以提供帮助
-
@charlietfl 我已经用一些附加信息编辑了这个问题,请看一下