Skip to main content

Posts

Showing posts with the label Angular Service

Angular service to handle form input elements

In the previous post , we have seen how the datatype mismatch cause an error in HTML5 Angularjs Form. We have see the remedy to remove those errors. Each time when we send and $http request to insert and item to MySQL database we have to convert the data according to the data format accepted by the database. If in our form has less number of input fields then we can change the data format of form data submit to server by converting each value. It is tedious to convert the data format for each input field if we have many input to handle. In that situation, we will make our code dirty and less maintainable and readable. To overcome all these type of difficulties, we have created an angular service to tackle it. Let's see the code for our angular service named $convertor: $convertor Service: var app = angular.module('myApp',[]); app.factory('$convertor',['dateFilter',function(dateFilter){ return{ convertForSQL : convertForSQL, convertForHTML5 : c...