Posts

Showing posts from April, 2016

Angular directive to validate a decimal input field with min/max

Image
I came across a requirement to validate a simple numeric input field with a minimum and a maximum value. So I tried using the html5 validations first like so    < input   type= "number"   name= "quantity"   min= "1"   max= "5" > The above works perfectly until you need to have decimal minimum and maximum values. So I thought why not write a directive to support this. The code can be found in the following GitHub repo https://github.com/kumudug/angular_min_max_validate  The directive supports the following Decimal min and max validation Decimal min value only validation Decimal max value only validation Usage <input type= "number" class= "form-control" id= "decimal1" name= "decimal1" ng-model= "vm.dec1" required ch-validate-min-max min-val= "0.2" max-val= "1.7" > Initial View After validation is triggered

Inline editing using ng-table

Image
I was working on an enterprise application that needed table in-line editing. I thought why engineer something from scratch when we can use something that's already out there. After doing some looking around ng-table was the preferred option. It supported sorting, filtering etc which were required functionalities but it didn't mention anything about in-line editing. So I started looking at the API on my own. I noticed that the API supports loading data using the "NgTableParams" and I used this service to control the view. Instead of blabbering on I will let the code do the talking. The sample code is hosted in the following GitHub url https://github.com/kumudug/ng-table-inline-editing The code supports the following Adding new items with validation Editing existing items with validation Deleting items with confirmation Undo add, edit and delete