[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 函数返回本身的第一个参数.这个函数一般用于函数风格. ----------以上是官网对该接口的说明,只能说这个文档写得也太二,让人完全看不懂.要理解它的用途,可直接看 ...
随机推荐
- MongoDB实战指南(四):MongoDB的Journaling日志功能
mongoDB的Journaling日志功能与常见的log日志是不一样的,mongoDB也有log日志,它只是简单记录了数据库在服务器上的启动信息.慢查询记录.数据库异常信息.客户端与数据库服务器连接 ...
- 使用NSURLSession实现断点续传
在sb中创建按钮,并且连线到.m文件中
- leetcode面试准备:Simplify Path
leetcode面试准备:Simplify Path 1 题目 Given an absolute path for a file (Unix-style), simplify it. For exa ...
- 正确使用c语言中的头文件
我们在使用c编程的时候经常会遇到头文件,前段时间我自己做了个小项目的时候,也遇到了关于头文件的问题. 预处理器发现#include 指令后,就会寻找后跟的文件名并把这个文件包含的内容包含到当前文件中. ...
- poj1141Brackets Sequence(dp+路径)
链接 dp好想 根据它定义的 记忆化下就行 路径再dfs一遍 刚开始以为要判空格 所以加了判空格的代码 后来知道不用 .. #include <iostream> #include< ...
- hduAnother Graph Game
http://acm.hdu.edu.cn/showproblem.php?pid=4647 很扯的一题 将每条边的一半权值分给它所连的两个结点 #include <iostream> # ...
- c#基础这些你都看过吗?(一)-----仅供初学者使用
1.注释(不写注释是流氓,名字瞎起是扯淡)‘///’一般用于注释函数,注释类.2.快捷键ctrl+k+d(有语法错误无法进行对齐)ctrl+j(快速弹出只能提示)shift+end,shift+hom ...
- Webform和MVC,为什么MVC更好一些?
前言 如果你看了最近微软的议程,你会发现他们现在的焦点除了MVC,还是MVC.问题在于为什么微软如此热衷于丢弃传统的APS.NET Webform而转向ASP.NET MVC?本文就主要来讨论这个问题 ...
- 深入.net平台和c#编程 学习笔记
深入.net平台和c#编程 一:理解.nteFramwork与c# 1.1,:Microsoft.net框架概述 1.2:.net框架结构 1.3.:c#语言概述 1.4:体验框架类库的强大功能 二: ...
- 【转】增加eclipse的运行内存 -- 不错!!
原文网址:http://blog.csdn.net/qa962839575/article/details/43605241 今天在eclipse 中测试把文档转换为图片的时候,报出了下面的错误: J ...