I have a text input for comments in an ionic app and, on form submission, need that to clear.
I have the form inside an ionic modal so I am assuming I am falling victim to an isolated scope, however, the form still needs to be cleared.. here is my controller (I have marked where I am trying to clear the form):
.controller('EasternInnerCtrl', function ($http, $timeout, $scope, $ionicLoading, $stateParams, $ionicScrollDelegate, $cordovaSocialSharing, $ionicModal, Easternc, AuthService) {
$scope.eastc = Easternc.get($stateParams.eastcId);
$ionicModal.fromTemplateUrl('commenter.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal
})
$scope.openModal = function() {
$scope.modal.show();
}
$scope.closeModal = function() {
$scope.modal.hide();
};
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
$scope.addComment = function(new_comment, comments){
Easternc.submitComment($scope.eastc.id, new_comment, comments).then(function(data){
if(data.status=="ok"){
var user = AuthService.getUser();
var comment = {
author: {name: user.data.username},
content: new_comment,
date: Date.now(),
user_gravatar : user.avatar,
id: data.comment_id
};
$scope.eastc.comments.push(comment);
$scope.new_comment = ""; // HERE IS WHERE I AM TRYING TO CLEAR THE FORM
$scope.new_comment_id = data.comment_id;
}
});
};
})