<!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. bzoj4525: [Usaco2016 Jan]Angry Cows

    二分. #include<cstdio> #include<algorithm> #include<cstring> using namespace std; + ...

  2. 在win2008中配置ServU

    因为08的防火墙要求比较高.很多端口都关闭,所以要设置防火墙. 首先设置入站规则 1.新建一条规则,规则类型选择“端口”,然后TCP,设置为20-21,60010-60020,然后允许链接,在配置文件 ...

  3. 怎么找到MyEclipse->add struts capabilities

    问:MyEclipse:我的工程右键可以MyEclipse->add struts capabilities之前有,后来不知怎么就没有了,谁知道怎么弄出来是struts 答:你已经add过一次了 ...

  4. POJ 1155-TELE(树形背包)

    题意:电视台发送信号给很多用户,每个用户(叶子节点)有愿意出的钱,电视台经过的路线都有一定费用,求电视台不损失的情况下最多给多少用户发送信号. 分析:问题与以i为根节点的子树所包含的叶子数 #incl ...

  5. ASP.NET服务器控件OnClientClick事件中Eval()作为js方法的参数的一种写法

    参考代码: <input type="button" OnClientClick='<%#Eval("DeptID", "DelUserD ...

  6. JavaScript:子ウィンドウから親ウィンドウを再読み込みさせる方法

    ことの起こり Webの画面では.新規入力をしようとすると.別ウィンドウ=子ウィンドウが開いて入力し.登録ボタンを押すと.子ウィンドウが閉じる仕組みがある. 子ウィンドウが閉じるだけなら問題ないが.一覧 ...

  7. linux oracle10g安装

    同样适合11g哦,亲; 一.安装系统 首先安装Linux系统,根据Oracle官方文档的建议,在机器内存小于1G的情况下,swap分区大小应该设置为内存的2倍大,若内存大于2G则swap分区设置为与内 ...

  8. HDU 1890--Robotic Sort(Splay Tree)

    题意:每次找出第i大的数的位置p输出,然后将i~p之间的数反转. 题解:每次把要的区间转成一棵子树,然后更新.因为每次将第i小的数转到了了i,所以k次操作后,可知前k个数一定是最小的那k个数,所以以后 ...

  9. dynamic调用时报RuntimeBinderException:“object”未包含“xxx”的定义 错误

    情况如下:两个项目项目A命名空间 Test.PA   匿名类型所在 项目B命名空间 Test.PB 在Test.PB 中通过dynamic关键字调用Test.PA中匿名类型时报上述错误 解决办法 在项 ...

  10. 获取最外层View

    获取最外层View activity.getWindow().getDecorView()