My angular controller method is quite simple :
$scope.addComment = function () {
if ($scope.newComment.message) {
$scope.can_add_comments = false;
new Comments({ comment: $scope.newComment }).$save(function (comment) {
$scope.comments.unshift(comment);
return $scope.can_add_comments = true;
});
return $scope.newComment = {};
}
};
In the form, I have a textarea where the comment value is stored :
<textarea class="required" cols="40" id="new_comment_message" maxlength="2500" ng-disabled="!can_add_comments" ng-model="newComment.message" required="required" rows="20"></textarea>
Everything works fine so far, but I also want to include some hidden data with the comment. So, I added a field for that value :
<input id="hash_id" name="hash_id" ng-init="__1515604539_122642" ng-model="newComment.hash_id" type="hidden" value="__1515604539_122642">
However, when I check the $scope.newComment
, it only shows an object with the message property, which is the value from the text area. The property hash_id
doesn't appear.
When I make this input visible and manually enter a value into the field before submitting the form, then I do get an object with the hash_id
property. What am I missing here? Am I not setting it up correctly?