Angular-formly allows you to keep your forms as DRY as possible. The property is one optionsTypes -of-A-composing your field configurations to keep your forms light-weight and DRY.
/*Global Angular*/(function() { ' Use strict '; varApp = Angular.module (' formlyexample ', [' formly ', ' formlybootstrap ']); App.run (function(formlyconfig) {formlyconfig.settype ({name:' IpAddress ', Defaultoptions: {templateoptions: {label:' IP address ', placeholder:' 127.0.0.1 '}, validators: {ipAddress:function($viewValue, $modelValue) {varValue = $modelValue | |$viewValue; return!value | |validateipaddress (value); }}}, controller:function($scope) {console.log ($scope); } }); functionvalidateipaddress (value) {returnValue &&/(\d{1,3}\.) {3}\d{1,3}/. Test (value); } }); App.controller (' Mainctrl ',functionMainctrl () {varVM = This; //funcation AssignmentVm.onsubmit =OnSubmit; //variable AssignmentVm.model = {}; Vm.fields=[{type:' Input ', Key:' IpAddress ', optionstypes: [' IpAddress '], Templateoptions: {label:' My IP address ' } } ]; //copy fields because formly adds data to them //That isn't necessary to show for the purposes //Of this lessonVm.originalfields =angular.copy (Vm.fields); //function Definition functionOnSubmit () {alert (json.stringify (Vm.model),NULL, 2); } });}) ();
[AngularJS] Angular-formly:default Options