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);
}
}

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

  1. Angular CLI 启动 版本ng 4

    npm install -g angular-cli ng -v ng new project_name cd project_name ng serve 浏览器打开输入 localhost:4200

  2. WinForm二三事(三)Control.Invoke&Control.BeginInvoke

    http://www.cnblogs.com/yuyijq/archive/2010/01/11/1643802.html 这个系列从2009年写到2010年,差点又成太监文.随着WPF/Silver ...

  3. angular报错:angular.min.js:118Error: [ng:areq] http://errors.angularjs.org/1.5.8/ng/areq

    报错代码如下: <div ng-controller="HelloAngular"> <p>{{greeting.text}},angular</p& ...

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

    1.Control.Invalidate会放一个WM_PAINT消息到消息队列,当Control处理到该消息的时候,就调用OnPaint. 2.Control.Refresh相当于以下两行:Contr ...

  5. (转)c# control.Invoke control.BeginInvoke

    在Invoke或者BeginInvoke的使用中无一例外地使用了委托Delegate. 一.为什么Control类提供了Invoke和BeginInvoke机制? 关于这个问题的最主要的原因已经是do ...

  6. Angular6之ng build | ng build --aot | ng build --prod 差异

    由于写了大半年的项目终于要告一段落并且即将进行第二阶段优化开发,emmm 基础版本已经二十多个模块了,必不可少的优化是很重要的,尽管项目上使用多层嵌套懒加载,但是在首屏加载的时候,任然很慢啊,因为一直 ...

  7. WinForm Control.Invoke&Control.BeginInvoke异步操作控件实例

    参考:http://www.cnblogs.com/yuyijq/archive/2010/01/11/1643802.html 效果图: 实例(实验)代码: using System; using ...

  8. angular 2 - 001 ng cli的安装和使用

    angular cli 创建项目和组件 ng new my-app --skip-install cd my-app cnpm install ng serve localhost:4200 angu ...

  9. [Angular 6] 初学angular,环境全部最新,[ ng serve ] 不能启动,卡在 95% 不动 => 解决方案

    2018.9.7 问题描述: 通过ng serve命令启动angular应用时,卡在95%, ctrl+c 停掉后看到错误内容为找不到ng_modules下的angular模块下的package.js ...

  10. Ngnice-国内ng学习网站

    今天给angular新手介绍一个国内开源的ng学习网站http://www.ngnice.com/这是由一批ng爱好者在雪狼大叔的带领下共同开发完成,致力于帮助更多的ng新人,他们分别是: ckken ...

随机推荐

  1. 浅说prop与attr的区别

    jquery中attr和prop的区别   在高版本的jquery引入prop方法后,什么时候该用prop?什么时候用attr?它们两个之间有什么区别?这些问题就出现了. 关于它们两个的区别,网上的答 ...

  2. truncate 命令删除恢复

    truncate命令可以一次性删除当前表中所有记录并且不留任何日志,同时这个表的ID就自动初化从1开始,今天我就来给大家尝试一个利用truncate清除记录之后恢复过程. 实际线上的场景比较复杂,当时 ...

  3. python str + int

    TypeError: cannot concatenate 'str' and 'int' objects 1. print 'Is your secret number " + str(p ...

  4. PuTTY + Xming 远程使用 Linux GUI

    from http://www.zw1840.com/blog/zw1840/2008/10/putty-xming-linux-gui.html 在家里的PC上用VMWare做了一个Oracle E ...

  5. django-orm-standalone

    django-orm-standalone script via:https://github.com/masnun/django-orm-standalone/ # Django specific ...

  6. linux中VI编辑器使用个人记录

    VI编辑器有三种编辑模式:命令模式.最后行模式.文本编辑模式 启动VI后进入的第一种模式是”命令模式“.从命令模式可进入最后行模式和编辑模式.而后两种模式之间不能直接切换.必须按ESC键退回到命令模式 ...

  7. Flip Game

    http://poj.org/problem?id=1753 #include<cstdio> #include<algorithm> #include<string.h ...

  8. ios入门之c语言篇——基本函数——3——判断日期是一年的第几天

    3.判断日期是一年的第几天 参数返回值解析: 参数: y:int,年份: m:int,月份 d:int,日期 返回值: sum:传入日期是当年的第几天: 函数解析: leapyear(y);判断y是不 ...

  9. MySQL使用rand函数实现随机数

    sql 的随机函数newID()和RAND() sql server的随机函数newID()和RAND() SELECT * FROM Northwind..Orders ORDER BY NEWID ...

  10. 【HDOJ】3442 Three Kingdoms

    bfs+状态压缩.初始化数组的曼哈顿距离条件写错了,改了一下午. /* 3442 */ #include <iostream> #include <cstdio> #inclu ...