<!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的更多相关文章

  1. [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 ...

  2. 【js类库AngularJs】解决angular+springmvc的post提交问题

    [js类库AngularJs]解决angular+springmvc的post提交问题 AngularJS诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀的前 ...

  3. [AngularJS] Introduction to ui-router

    Introduce to basic $stateProvider.state() with $stateParams services. Understand how nested router w ...

  4. [AngularJS] Lazy loading Angular modules with ocLazyLoad

    With the ocLazyLoad you can load AngularJS modules on demand. This is very handy for runtime loading ...

  5. [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 ...

  6. [AngularJS] New in Angular 1.5 ng-animate-swap

    <!DOCTYPE html> <html ng-app="MyApplication"> <head> <link rel=" ...

  7. AngularJS进阶(五)Angular实现下拉菜单多选

    Angular实现下拉菜单多选 写这篇文章时,引用文章地址如下: http://ngmodules.org/modules/angularjs-dropdown-multiselect http:// ...

  8. AngularJS进阶(四)ANGULAR.JS实现下拉菜单单选

    ANGULAR.JS: NG-SELECT AND NG-OPTIONS PS:其实看英文文档比看中文文档更容易理解,前提是你的英语基础还可以.英文文档对于知识点讲述简明扼要,通俗易懂,而有些中文文档 ...

  9. [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 ...

随机推荐

  1. struts2关于package 的 namespace

    namespace决定了action的访问路径,默认为"",可以接收所有路径的actionnamespace可以写为/ ,或者/xxx,或者/xxx/yyy,对应的action访问 ...

  2. 手机web开发

    jqmobi 可以代理 jquery mobile,似乎更加小和快 http://app-framework-software.intel.com/components.php   bootstrap ...

  3. poj3321

    树映射到树状数组上 非常好的题目,给了我很多启发 题目要求动态求一个棵子树的节点个数 不禁联想到了前缀和,只要我们能用一个合适的优先级表示每个顶点,那么就好做了 我们可以考虑将子树表示成区间的形式 这 ...

  4. ↗☻【编写可维护的JavaScript #BOOK#】第9章 将配置数据从代码中分离出来

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8& ...

  5. NK 1137: 石子合并问题

     1137: 石子合并问题 Time Limit: 1500 ms    Memory Limit: 10000 kB    Judge type: Multi-cases Total Submit ...

  6. Hibernate4.x之入门篇

    Hibernate作为一个优秀的持久化框架.ORM框架.在日常的Java开发中常常用到.本文主要通过一个简单的例子来介绍下Hibernate4.x的入门知识. 新建一个Java项目,并加入Hibern ...

  7. 初次接触Object对象变量

    Object 变量存储为 32 位(4 个字节)的地址形式,其为对象的引用.利用 Set 语句,声明为 Object 的变量可以赋值为任何对象的引用. 第一次注意到还有个数据类型,帮助文件里只有上面这 ...

  8. selenium Grid

    Selenium Grid 的机制是启动一个 hub,然后启动多个 Selenium RC 注册到 hub 上, 当测试请求到 hub 时,hub 会将测试分发给 Selenium RC, Selen ...

  9. 配置OpenGL及第一个实例

    Windows环境下安装GLUT的步骤:1.将下载的压缩包解开,将得到5个文件2.在“我的电脑”中搜索“gl.h”,并找到其所在文件夹(如果是VS,则应该是其安装目录下面的“VC\PlatformSD ...

  10. 利用CryptoStream进行加密解密

    public class DBSecurity { //sKey sIV这两个自己随意设定,不能外泄 private const string sKey = "11,22,33,43,34, ...