[Angular 2] ng-control & ng-control-group

Control:

Controls encapsulate the field‘s value, a states such as if it is valid, dirty or has errors.

var nameControl = new Control("Nate");
var name = nameControl.value; // -> Nate

nameControl.errors // -> StringMap<string, any> of errors
nameControl.dirty // -> false
nameControl.valid // -> true

ControlGroup:

A way to manage multiple Controls.

var personInfo = new ControlGroup({
    firstName:  new Control("Nate"),
    lastName: new Control("Murray"),
    zip: new Control(‘90210‘)
});

personInfo.value; // ->{
   //firstName: "Nate",
   //lastName: "Murray",
   //zip: "90210"
}

personInfo.errors // -> StringMap<string, any> of errors
personInfo.dirty // -> false
personInfo.valid // -> true
import {Component, View, FORM_DIRECTIVES} from ‘angular2/angular2‘;

@Component({
    selector: ‘demo-form-sku‘
})
@View({
    directives: [FORM_DIRECTIVES],
    template: `
       <div>
        <h2>Demo Form: Sku</h2>
        <!-- ngForm is attched to the form, and #f="form" form is also come from ngForm-->
        <form #f = "form"
        (submit)="onSubmit(f.value)">
            <div class="form-group">
                <label for="skuInput">SKU</label>
                <input type="text"
                class="form-control"
                id="skuInput"
                placeholder="SKU"
                ng-control="sku">
            </div>

            <button type="submit" class="btn btn-default">
                Submit
            </button>
        </form>
       </div>
    `
})

export class DemoFormSku {
    constructor() {

    }

    onSubmit(value){
        console.log(value);
    }
}

时间: 2024-10-12 03:39:02

[Angular 2] ng-control & ng-control-group的相关文章

Control.Refresh Control.Invalidate 和 Control.OnPaint之间的联系和区别

1.Control.Invalidate会放一个WM_PAINT消息到消息队列,当Control处理到该消息的时候,就调用OnPaint. 2.Control.Refresh相当于以下两行:Control.Invalidate(true);Control.Update(); 3.Control.Update会搜索消息队列,如果找到WM_PAINT,就把它取出,'直接'调用OnPaint. 因此,Invalidate告诉系统当前窗口要求重画,但不要求立即执行,那些排在WM_PAINT前面的消息会先

A GUIDE TO UNDERSTANDINGDISCRETIONARY ACCESS CONTROL INTRUSTED SYSTEMS

1. INTRODUCTION ? The main goal of the National Computer Security Center is to encourage the widespread availability of trusted computer systems. In support of that goal a metric was created, the Department of Defense Trusted Computer System Evaluati

Ngnice-国内ng学习网站

今天给angular新手介绍一个国内开源的ng学习网站http://www.ngnice.com/这是由一批ng爱好者在雪狼大叔的带领下共同开发完成,致力于帮助更多的ng新人,他们分别是: ckken,grahamle,NigelYao,asnowwolf,lightma,joeylin,FrankyYang,lrrluo, why520crazy,破狼,二当家, Ken, zxsoft, why520crazy, playing,天猪.jacobdong.以及一批后加入或审校未记名的社区爱好者

Control File管理

什么是Control file 每个Oracle database都有控制文件, 是一个很小的二进制文件,存储了数据库的物理结构. 内容包括 The database name datafile, redo log file位置和文件名 The timestamp of the database creation The current log sequence number Checkpoint information SQL>show parameter control control_fi

cocos2d-x 源码分析 : control 源码分析 ( 控制类组件 controlButton)

源码版本来自3.1rc 转载请注明 cocos2d-x源码分析总目录 http://blog.csdn.net/u011225840/article/details/31743129 1.继承结构 control的设计整体感觉挺美的,在父类control定义了整个控制事件的基础以及管理,虽然其继承了Layer,但其本身和UI组件的实现并没有关联.在子类(controlButton,controlSwitch,controlStepper等中实现不同的UI组件).下面通过源码来分析control与

Create Hierarchical Tree To Control Records In Oracle Forms

Download Source Code Providing an example form for creating hierarchical trees in Oracle Forms to control data block records. In this form whenever user selects any node in tree menu then corresponding record is displayed at right side. This form is

命令行界面下使用emca安装配置Oracle Database Control实战

作为命令行忠实用户,服务器端软件的运维都倾向于使用命令或 脚本完成,非常讨厌资源占用很大的GUI.Oracle数据库作为重要的服务器端软件,其安装运维自然也完全支持纯命令行方式,尽管同时提供了OUI这个GUI安装程序.至于纯命令行下静默安装Oracle11g,本人之前写过详细的博文,有需要的请参考之,博文地址http://blog.csdn.net/smstong/article/details/7352036.按照这篇博文安装的数据库完全可用.本文算是对前面这篇博文的一个补充,就是在数据库安装

System.Windows.Forms.Control : Component, IOleControl, IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject....

#region 程序集 System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll #endregion using System.Collections; using System.ComponentModel; using Syst

WinForm中Component Class、User Control及Custom Control的区别和使用建议

reference: http://blog.csdn.net/redstonehe/article/details/1536549 .NET Framework 为您提供了开发和实现新控件的能力.除了常见的用户控件外,现在您会发现,您可以编写能执行自身绘图的自定义控件,甚至还可以通过继承扩展现有控件的功能.确定创建何种类型的控件可能会费一番功夫.本节重点介绍了各类可继承控件间的区别,同时提供关系到为项目选择的类型的注意事项. 1. Component Class Component Class

Stream Player control

In this article you will find an implementation of a stream player control. Download WPF demo - 11 MB Download WinForms demo - 11 MB Download WPF sources - 11 MB Download WinForms sources - 11 MB Download FFmpeg facade sources - 16.8 KB Introduction