Client Side
Users = new Mongo.Collection("user-info");
if (Meteor.isClient) {
var myApp = angular.module('calorie-counter', ['angular-meteor']);
myApp.controller('formCtrl', ['$scope', function ($scope) {
$scope.user = {
item1: 0,
item2: 0
};
$scope.submit = function () {
Meteor.call("submit" ($scope.user));
}
}]);
}
Server side:
if (Meteor.isServer) {
Meteor.methods({
submit: function (user) {
Users.insert(user);
}
});
}
What I'm attempting to do is when the user clicks on the submit button on the client side, I want it to call a server side method where the information that the User entered will be saved into the collection. I'm passing in the $scope.user as a parameter (not too sure if I'm calling the method correctly) but the error I keep receiving is "submit is not a function". Initially, I was just inserting the $scope.user directly from that function, but I thought that type of an operation might be more suitable for the server side? (I'm not too sure if I'm thinking of this right or just overthinking)