[AngularJS] Introduction to angular-formly
<!DOCTYPE html>
<html> <head>
<!-- Each of these scripts are the latest version of the library at the time this jsbin was created --> <!-- Twitter bootstrap -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css"/>
<!-- api-check is a dependency of angular-formly -->
<script src="bower_components/api-check/dist/apiCheck.min.js"></script> <!-- angular.js is a dependency of angular-formly (obviously) -->
<script src="bower_components/angular/angular.min.js"></script> <!-- This is angular-formly -->
<script src="bower_components/angular-formly/dist/formly.min.js"></script> <!-- This is a bootstrap template libraray giving us some pre-defined types for bootstrap -->
<script src="//rawgit.com/formly-js/angular-formly-templates-bootstrap/4.0.3/dist/angular-formly-templates-bootstrap.js"></script> <title>Angular Formly Lesson</title>
</head> <body ng-app="formlyExample" ng-controller="MainCtrl as vm">
<div>
<h1>
angular-formly: Introduction<br />
<small>Egghead.io lesson by @kentcdodds</small>
</h1>
<form name="vm.form" ng-submit="vm.onSubmit()" novalidate>
<formly-form model="vm.model" fields="vm.fields"></formly-form>
<button type="submit" class="btn btn-primary submit-button">Submit</button>
</form> <form name="vm.form" ng-submit="vm.onSubmit()" novalidate>
<div class="form-group">
<label for="firstName">First Name</label>
<input ng-model="vm.model.firstName" id="firstName" name="firstName" class="form-control" />
</div>
<button type="submit" class="btn btn-primary submit-button">Submit</button>
</form>
<h2>Model</h2>
<pre>{{vm.model | json}}</pre>
<h2>Fields <small>(note, functions are not shown)</small></h2>
<pre>{{vm.originalFields | json}}</pre>
<h2>Form</h2>
<pre>{{vm.form | json}}</pre>
</div>
<script src="app.js"></script>
</body> </html>
/* global angular */
(function() { 'use strict'; var app = angular.module('formlyExample', ['formly', 'formlyBootstrap']); app.controller('MainCtrl', function MainCtrl() {
var vm = this;
// funcation assignment
vm.onSubmit = onSubmit; // variable assignment
vm.model = {
firstName: 'Obi Wan',
something: {name: "default",value:"default"}
};
vm.fields = [
{
type: 'input',
key: 'firstName',
templateOptions: {
label: 'First Name'
}
},
{
template: '<hr />'
},
{
type: 'select',
key: 'something',
templateOptions: {
label: 'Select Somthing',
options: [
{name: "wan", value: "Wan"},
{name: "obi", value: "Obi"},
{name: "Yui", value: "yui"}
]
}
}
]; // 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] Introduction to angular-formly的更多相关文章
- [Angular] Use Angular components in AngularJS applications with Angular Elements
When migrating AngularJS (v1.x) applications to Angular you have different options. Using Angular El ...
- 【js类库AngularJs】解决angular+springmvc的post提交问题
[js类库AngularJs]解决angular+springmvc的post提交问题 AngularJS诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀的前 ...
- [AngularJS] Introduction to ui-router
Introduce to basic $stateProvider.state() with $stateParams services. Understand how nested router w ...
- [AngularJS] Lazy loading Angular modules with ocLazyLoad
With the ocLazyLoad you can load AngularJS modules on demand. This is very handy for runtime loading ...
- [AngularJS] New in Angular 1.3 - Performance Boost with debugInfoEnabled
By default, Angular provides a lot of debug information on the DOM that's only necessary for tools l ...
- [AngularJS] New in Angular 1.5 ng-animate-swap
<!DOCTYPE html> <html ng-app="MyApplication"> <head> <link rel=" ...
- AngularJS进阶(五)Angular实现下拉菜单多选
Angular实现下拉菜单多选 写这篇文章时,引用文章地址如下: http://ngmodules.org/modules/angularjs-dropdown-multiselect http:// ...
- AngularJS进阶(四)ANGULAR.JS实现下拉菜单单选
ANGULAR.JS: NG-SELECT AND NG-OPTIONS PS:其实看英文文档比看中文文档更容易理解,前提是你的英语基础还可以.英文文档对于知识点讲述简明扼要,通俗易懂,而有些中文文档 ...
- [AngularJS] Using the Angular scope $destroy event and method
With Angular scopes, you have access to a $destroy event that can be used to watch $scope events. Th ...
随机推荐
- CSS sprites 技术
Css Sprites 技术逐渐流行,各大网站上都可以看到它的身影. 但从本质上,Css Sprites 只是 Css 技术的一个使用小窍门,初学者也能快速上手. Css Sprites 简单解释: ...
- POJ 2391 Ombrophobic Bovines ★(Floyd+二分+拆点+最大流)
[题意]有n块草地,一些奶牛在草地上吃草,草地间有m条路,一些草地上有避雨点,每个避雨点能容纳的奶牛是有限的,给出通过每条路的时间,问最少需要多少时间能让所有奶牛进入一个避雨点. 和POJ2112很类 ...
- SharePoint2010 自定义代码登录方法
转:http://yysyb123.blog.163.com/blog/static/192050472011382421717/ SharePoint2010 自定义代码登录方法 (自定义Form验 ...
- Beginning Android 4 Programming Book学习
Chapter 3 EditText不自动获取焦点,自动获取焦点但不显示软键盘 Page 122-123 只有定义了android:id属性的控件在屏幕翻转后状态才会被持久化 Page 133 C ...
- java中两种类型变量
Java中有两种类型的变量,一种是对象类型,另一种是基础类型(primitive type). 对象类型普遍采用引用的方式,比如 List a = new ArrayList(); List b = ...
- HDU 4825-Xor Sum(trie)
题意: 给你一组数,开始询问给一个数 求组中与该数异或值最大的数. 分析:根据异或的特点 要想得到的异或值最大 尽可能的让两个数的每位都相反 先把给定的一组数建树,数的最后一位对应的节点保存这个数的 ...
- 房租管理小软件(四):对linq的使用
1.对LInq的封装如下: private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMap ...
- 【原】Redis-LRU缓存
Redis高级篇 Redis-LRU缓存 将Redis作为缓存使用时,有时添加新数据时,旧数据是很难被清空的. LRU(Least Recently Used) 近期最少使用算法是常用算法之一. 最大 ...
- [原]Android开发环境搭建
[Date]2014-04-20 [Author]wintys (wintys@gmail.com) http://wintys.cnblogs.com [Keywords]android . 离线a ...
- bzoj 2815 [ZJOI2012]灾难(构造,树形DP)
[题意] 求把每个点删除后,不可达点的数目. [思路] 构造一棵“灭绝树”,要求这棵树满足如果删除根节点后则该子树内的所有结点都不可达.则答案为子树大小-1. 如何构造这棵“灭绝树”? 将原图拓扑排序 ...