There are two main functions we’ll use on FormBuilder:

• control - creates a new Control
• group - creates a new ControlGroup

import {Component, bootstrap, View} from "angular2/angular2";
import {FORM_DIRECTIVES, FormBuilder, ControlGroup} from "angular2/angular2"; @Component({
selector: 'demo-form-sku-builder'
})
@View({
directives: [FORM_DIRECTIVES],
template: `
<div>
<h2>Demo Form: Sku with Builder</h2>
<form [ng-form-model]="myForm"
(submit)="onSubmit(myForm.value)">
<div class="form-group">
<label for="skuInput">SKU</label>
<input type="text"
class="form-control"
id="skuInput2"
placeholder="SKU2"
[ng-form-control]="myForm.controls['sku2']">
<label for="skuInput">Demo</label>
<input type="text"
class="form-control"
id="demo"
placeholder="Demo"
[ng-form-control]="myForm.controls['demo']">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
`
})
export class DemoFormSkuBuilder {
myForm: ControlGroup;
constructor(fb: FormBuilder) {
this.myForm = fb.group({
"sku2": ["ABC123"],
"demo": ["I am demo"]
})
} onSubmit(value) {
console.log(value);
}
}

[Angualr 2] Using FormBuilder的更多相关文章

  1. [Angualr 2] Watch for changes

    You can watch for form / control changes by using .valueChanges.observe({...}): this.sku.valueChange ...

  2. angualr Material Icons

    首先需要项目引入 angualr meterial icons的资源库 图标资源链接 https://klarsys.github.io/angular-material-icons/ <md- ...

  3. 怎么使用formBuilder以拖拽方式编写页面

    1.以admin用户登录系统,打开formbuilder http://localhost:8081/framework/main/formbuilder 2.从右方组件中,用鼠标拖拽页面所需的组件到 ...

  4. [Angular2 Form] Reactive Form, FormBuilder

    Import module: import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/comm ...

  5. Angular2+之使用FormGroup、FormBuilder和Validators对象控制表单(取值、赋值、校验和是否可编辑等)

    1.要使用Angular自带的表单控制需要先引入相关模块(.ts文件): import { FormGroup, //表单对象类 FormBuilder, //表单生成工具类 Validators} ...

  6. Laravel Form-builder使用

    添加formbuilder插件: Composer应用 composer require kris/laravel-form-builder 下载成功 修改配置文件 在config/app.php ‘ ...

  7. angualr 实现tab选项卡功能

    tab.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  8. ORACLE FormBuilder触发器执行顺序

    1.当打开FORM时: (1)PRE-FORM (2)PRE-BLOCK(BLOCK级) (3)WHEN-NEW-FORM-INSTANCE (4)WHEN-NEW-BLOCK-INSTANCE (5 ...

  9. ng-clip angualr 的copy功能

    每次写博客都想由衷的给我的老大膜拜一番!以前刚开始做angular的项目的时候就有说要有点击复制的功能因为当时菜啊,不懂啊.也就没做,今天老大又给了我一个资料!“ng-clip”.跟着老大最大的收获就 ...

随机推荐

  1. img超出div width时, jQuery动态改变图片显示大小

    参考: 1. http://blog.csdn.net/roman_yu/article/details/6641911 2. http://www.cnblogs.com/zyzlywq/archi ...

  2. 【转】python中List的sort方法(或者sorted内建函数)的用法

    原始出处:http://gaopenghigh.iteye.com/blog/1483864 python列表排序 简单记一下python中List的sort方法(或者sorted内建函数)的用法. ...

  3. List<String^>^ 引用空间

    莫名其妙报错 需要在.h和.cpp文件中都引用: using namespace System::Collections;using namespace System::Collections::Ge ...

  4. 长期支持版本(即不自动更新版本) - Flash Player 18.0.0.268

    无意中发现,适合不喜欢折腾的朋友. 下载链接:(官方:http://www.adobe.com/cn/products/flashplayer/distribution3.html) (分流:http ...

  5. Java Web开发介绍

    转自:http://www.cnblogs.com/pythontesting/p/4963021.html Java Web开发介绍 简介 Java很好地支持web开发,在桌面上Eclipse RC ...

  6. OSSchedLock()函数透析

    uC/OS-II的OSSchedLock()和OSSchedUnlock()函数允许应用程序锁定当前任务不被其它任务抢占. 使用时应当注意的是:当你调用了OSSchedLock()之后,而在调用OSS ...

  7. Oracle问题解决(远程登录失败)

    远程机: 安装 Oracle 的计算机: 本地机: 访问远程机 Oracle 的计算机. 一.问题描述 远程机安装 Oracle 成功. 本地机配置 InstantClient 后, PLSql De ...

  8. [BZOJ 1303] [CQOI2009] 中位数图 【0.0】

    题目链接:BZOJ - 1303 题目分析 首先,找到 b 的位置 Pos, 然后将数列中小于 b 的值赋为 -1 ,大于 b 的值赋为 1 . 从 b 向左扩展,不断算 Sum[i, b - 1] ...

  9. STM32F10x 学习笔记5(USART实现串口通讯 1)

    STM32F10x 系列单片机中都包含了USART 模块,所谓USART,就是通用同步异步收发器.通用同步异步收发器(USART)提供了一种灵活的方法与使用工业标准NRZ异步串行数据格式的外部设备之间 ...

  10. POJ2442 Sequence

    题目链接. #include <iostream> #include <cstdio> #include <cstring> #include <cstdli ...