how to handle empty input on angular?
I want validate on back end not on front end. But when i submit it return me error if i let it blank on icon input
TypeError: Cannot read property 'icon' of undefined
Here is my form:
<div class="form-group">
<div class="form-material form-material-danger">
<input class="form-control" type="text" id="name" ng-model="menu.name" placeholder="Menu Name.." empty-to-null>
<label for="name">Name</label>
</div>
</div>
<div class="form-group">
<div class="form-material form-material-danger">
<input class="form-control" type="text" id="icon" ng-model="menu.icon" placeholder="Menu Icon.." >
<label for="icon">Icon</label>
</div>
</div>
Here is my code:
var data = {
icon: $scope.menu.icon,
name: $scope.menu.name
};
AdminMenu.save(data, function (response) {
console.log(response);
$scope.menu = null;
ResultService(response);
$scope.dtInstance.reloadData();
}, function (response) {
ResultService(response.data);
})
.$promise.finally(function () {
$scope.button_text = "Store";
$scope.loading = false;
});
menuobject created, and where is thedataobject used?