Hello,
Currently, I try to make some database calls server-side due better performance. I built this test:
<md-button ng-click="view1.callTestfunction()"> Test!</md-button>
<h1>{{view1.getTestData}}</h1>
This is my client-side code:
//some code skipped
class View1 {
constructor($interval, $scope, $reactive ) {
'ngInject';
$reactive(this).attach($scope);
this.helpers({
getTestData(){
Meteor.call('allTestData',function(error, result){
if(error){
alert('Error');
}else{
return result;
}
});
}
});
}
callTestfunction(){
Meteor.call('allTestData',function(error, result){
if(error){
alert('Error');
}else{
console.log(result);
}
});
}
This is my code on the server side:
//some code skipped
Meteor.methods({
allTestData:()=>{
var results=Kafkadata.find().count();
console.log(results);
return results;
},
});
If I click on the test button it shows me the count of the db entries. But I dont want to use with a button. I want to use it with a helper. But view1.getTestData doesnt show anything. Is this the right way to use meteor methods with a helper? What am I doing wrong here?