[AngularJS] angular-formly: Default Options
angular-formly allows you to keep your forms as DRY as possible. TheoptionsTypes
property is one way of composing your field configurations to keep your forms light-weight and DRY.
/* global angular */
(function() { 'use strict'; var app = 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) {
var value = $modelValue || $viewValue;
return !value || validateIpAddress(value);
}
}
},
controller: function($scope) {
console.log($scope);
}
}); function validateIpAddress(value) {
return value && /(\d{1,3}\.){3}\d{1,3}/.test(value);
} }); app.controller('MainCtrl', function MainCtrl() {
var vm = this;
// funcation assignment
vm.onSubmit = onSubmit; // variable assignment
vm.model = {};
vm.fields = [
{
type: 'input',
key: 'ipAddress',
optionsTypes: ['ipAddress'],
templateOptions: {
label: 'My IP Address'
}
}
]; // copy fields because formly adds data to them
// that is not necessary to show for the purposes
// of this lesson
vm.originalFields = angular.copy(vm.fields); // function definition
function onSubmit() {
alert(JSON.stringify(vm.model), null, 2);
}
}); })();
[AngularJS] angular-formly: Default Options的更多相关文章
- [AngularJS] Angular 1.3 $submitted for Form in Angular
AngularJS 1.3 add $submitted for form, so you can use $submitted to track whether the submit event ...
- [AngularJS] Angular 1.3 Anuglar hint
Read More: http://www.linkplugapp.com/a/953215 https://docs.google.com/document/d/1XXMvReO8-Awi1EZXA ...
- [AngularJS] Angular 1.3 ng-model-options - getterSetter
getterSetter: boolean value which determines whether or not to treat functions bound to ngModel as ...
- [AngularJS] Angular 1.3: ng-model-options updateOn, debounce
<!DOCTYPE html> <html ng-app="app"> <head lang="en" > <meta ...
- [Angularjs]angular ng-repeat与js特效加载先后导致的问题
写在前面 最近在项目中遇到这样的一个前端的bug,在ng-repeat中绑定的图片,有一个晃动的特效,在手机端浏览的时候,图片有时候会正常展示,有时就展示不出来.当时猜测是因为angularjs与特效 ...
- [AngularJS] Angular 1.5 $transclude with named slot
In Angular 1.5, there is no link and compile. So use if you transclude, you cannot access the fifth ...
- [AngularJS] Angular 1.5 multiple transclude
If you know ui-router, multi-transclude should be easy for you also. In previou Angular version < ...
- [AngularJS] Angular 1.3 ngMessages with ngAnimate
Note: Can use $dirty to check whether user has intracted with the form: https://docs.angularjs.org/a ...
- AngularJs angular.identity和angular.noop详解
angular.identity 函数返回本身的第一个参数.这个函数一般用于函数风格. ----------以上是官网对该接口的说明,只能说这个文档写得也太二,让人完全看不懂.要理解它的用途,可直接看 ...
随机推荐
- linux相关办公软件汇总
ubuntu pdf阅读器 FoxitReader_1.1.0_i386.deb ubuntu 下的PDF阅读器(超级好使) Ubuntu下的chm和PDF阅读器 ubuntu便签软件xpad sud ...
- 获取C#中exe程序的实例名
获取sanjiao.frmsanjiao string strPass = @"D:\WinAutoTest\sanjiao.exe"; Assembly assebly = As ...
- 忘记commit的一次教训
由于业务需求,已经上线的系统新增加了一些需求,其中一个需求是,从一个SQLSERVER数据库导入数据到生产的ORCLE数据库, 由于我的失误导致系统上线后 生产的Oracle数据没有导入成功,但是在本 ...
- Objective-c Category(类别)
NSStringUtilities.h: #import <Foundation/Foundation.h> @interface NSString(Utilities) -(BOOL) ...
- Linux下搭建BT服务器
P2P(Peer to Peer 即对等网络)就是在这种背景下提出的一种网络技术,P2P可以简单地定义为通过直接交换信息,共享计算机资源和服务,对等计算机兼有客户机和服务器的功能.在这种网络中所有的节 ...
- 知识面 z
http://blog.csdn.net/sxhelijian/article/details/23163683 有了较宽和知识面,面对复试中不知道的问题,回答可以是:“这个问题,直接回答我没有把握, ...
- HDU-1238 Substrings
Substrings Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- [Rosa]Android ListView 适配器原理及优化(转)
ListView的Adapter的作用如下图所示: Adapter的作用就是ListView界面与数据之间的桥梁,当列表里的每一项显示到页面时,都会调用Adapter的getView方法返回一个V ...
- Failed to load unit 'PATM' (VERR_SSM_FIELD_NOT_CONSECUTIVE)
今天打开虚拟机启动的时候报错:Failed to load unit 'PATM' (VERR_SSM_FIELD_NOT_CONSECUTIVE) 后来发现虚机处于休眠状态,所以在虚机上右键,然后清 ...
- 【JS】Intermediate5:Scope
1.Scope=variable visibility a variable’s scope is the part of your code that can access and modify t ...