I am using SPA,I was trying to make this field is mandatory when we click on save button but it's saving as null, Here I am using ng-form
but not form
Here is my code:
event.html:
<div ng-form="eventForm" class="modal-content">
<div class="form-group">
<label>Place*</label> <input type="text" class="form-control" required
name="eventPlace" id="eventPlace" ng-model="eventVO.eventPlace" />
<div ng-show="eventForm.eventPlace.$touched">
<span ng-show="eventForm.eventPlace.$error.required">This
field is required.</span>
</div>
</div>
<a class="btn btn-success" ng-click="saveEvent()"
title="Click to save event">Save</a>
</div>
EventController.js:
$scope.saveEvent = function() {
debugger;
$scope.eventVO.userId = Session.userId;
$scope.eventVO.eventStartDate = moment($scope.eventVO.eventStartDate).format('YYYY-MM-DD HH:mm a');
$http({
url : "/event/add",
method : 'POST',
dataType : 'json',
'headers' : {
'Content-Type' : 'application/json'
},
data : $scope.eventVO
}).then(function(dataResponse) {
debugger;
if (dataResponse.data.status == "success") {
notify('Event saved successfully');
$(".add-event-modal").modal("hide");
$scope.getEvents();
$scope.clearModal();
} else {
notify('Error occured While Saving Event');
}
});
};
It is showing that 'This field is required' but saving when we click on Save button. How to make this field mandatory?
Note: Here I am not using submit
when click on save.