<!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. 大四实习准备5_android广播机制

    2015-5-1 android 广播机制 5.1简介 分为标准广播(Normal broadcasts)(无先后顺序,几乎同时接收,不可截断)和有序广播(Ordered broadcasts)(有先 ...

  2. mysql 读取硬盘数据

    innodb 的最小管理单位是页 innodb的最小申请单位是区,一个区 1M,内含64个页,每个页16K ,即 64*16K=1M, 考虑到硬盘局部性,每次读取4个区,即读4M的数据加载至内存 线性 ...

  3. 设计模式 - observer

    简单来讲,就是observer依赖于subject,当subject发生变化时,observer得到通知,并将状态与subject同步,常来用于维护对象间状态的一致性. observer的工作过程大体 ...

  4. Webapp meta标签解决移动缩放的问题

    webapp开发初期,会碰到在pc端开发好的页面在移动端显示过大的问题,这里需要在html head中加入meta标签来控制缩放 <meta name=" viewport" ...

  5. oracle 字段上下两条记录的相减

    SELECT T.ID  ,BALANCE,nvl(lag (BALANCE,1) over (order by T.ID ) ,0) FROM  AN T ORDER BY T.ID [转]orac ...

  6. C++学习笔记:List容器

    http://www.cplusplus.com/reference/list/list/ #include <list> list l:初始化一个0大小的表 list l(10):初始化 ...

  7. SharePoint 2013 入门教程--系列文章

    转:http://www.cnblogs.com/jianyus/p/3381415.html 以下文章是自己在学习SharePoint的过程中,不断积累和总结的博文,现在总结一个目录,分享给大家.这 ...

  8. 自定义 SharePoint 2010 快速启动栏和顶部链接栏

    转:http://vickynuli.blog.163.com/blog/static/180438492201281434249486/ 在网上找到篇文章,自定义快速启动栏和顶部链接栏,以下为代码, ...

  9. 解析activity之间数据传递方法的详解

    转自:http://www.jb51.net/article/37227.htm 本篇文章是对activity之间数据传递的方法进行了详细的分析介绍,需要的朋友参考下     1  基于消息的通信机制 ...

  10. MFC中状态栏显示鼠标坐标位置

    原文:MFC中状态栏显示鼠标坐标位置,蝈蝈 1,利用MFC向导创建一个应用工程ewq. 2,打开ResourceView,右击Menu菜单,插入Menu,在空白处双击,Caption中填入Point. ...