我尝试使用此angular bootstrap feedback form收集用户反馈数据并将信息索引到Elasticsearch(以使其可搜索)。
所以在我的SearchService for Elasticsearch中,我只是做了:
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-model并在我的控制器中添加了
//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(),以便将表单数据编入索引?
答案 0 :(得分:0)
经过上述试验和错误后发布。我决定看看是否有其他可用的东西。有is and its amazingly simple要实施。只需添加提交的网址即可!只需几分钟就能启动并运行(一旦我意识到我必须提供网址)。
HTH任何人。