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

[Angular 2] ng-control & ng-control-group的更多相关文章
- Angular CLI 启动 版本ng 4
npm install -g angular-cli ng -v ng new project_name cd project_name ng serve 浏览器打开输入 localhost:4200
- WinForm二三事(三)Control.Invoke&Control.BeginInvoke
http://www.cnblogs.com/yuyijq/archive/2010/01/11/1643802.html 这个系列从2009年写到2010年,差点又成太监文.随着WPF/Silver ...
- 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& ...
- Control.Refresh Control.Invalidate 和 Control.OnPaint之间的联系和区别
1.Control.Invalidate会放一个WM_PAINT消息到消息队列,当Control处理到该消息的时候,就调用OnPaint. 2.Control.Refresh相当于以下两行:Contr ...
- (转)c# control.Invoke control.BeginInvoke
在Invoke或者BeginInvoke的使用中无一例外地使用了委托Delegate. 一.为什么Control类提供了Invoke和BeginInvoke机制? 关于这个问题的最主要的原因已经是do ...
- Angular6之ng build | ng build --aot | ng build --prod 差异
由于写了大半年的项目终于要告一段落并且即将进行第二阶段优化开发,emmm 基础版本已经二十多个模块了,必不可少的优化是很重要的,尽管项目上使用多层嵌套懒加载,但是在首屏加载的时候,任然很慢啊,因为一直 ...
- WinForm Control.Invoke&Control.BeginInvoke异步操作控件实例
参考:http://www.cnblogs.com/yuyijq/archive/2010/01/11/1643802.html 效果图: 实例(实验)代码: using System; using ...
- angular 2 - 001 ng cli的安装和使用
angular cli 创建项目和组件 ng new my-app --skip-install cd my-app cnpm install ng serve localhost:4200 angu ...
- [Angular 6] 初学angular,环境全部最新,[ ng serve ] 不能启动,卡在 95% 不动 => 解决方案
2018.9.7 问题描述: 通过ng serve命令启动angular应用时,卡在95%, ctrl+c 停掉后看到错误内容为找不到ng_modules下的angular模块下的package.js ...
- Ngnice-国内ng学习网站
今天给angular新手介绍一个国内开源的ng学习网站http://www.ngnice.com/这是由一批ng爱好者在雪狼大叔的带领下共同开发完成,致力于帮助更多的ng新人,他们分别是: ckken ...
随机推荐
- C# 线程间互相通信
C#线程间互相通信主要用到两个类:AutoResetEvent和ManualResetEvent. 一.AutoResetEvent AutoResetEvent 允许线程通过发信号互相通信,线程通过 ...
- Invoke()/BeginInvoke()区别
查看MSDN如下: Control..::.Invoke ---> 在拥有此控件的基础窗口句柄的线程上执行委托. Control..::.BeginInvoke ---> ...
- 解决Collection was modified; enumeration operation may not execute异常
今天在使用foreach循环遍历list集合时,出现Collection was modified; enumeration operation may not execute.这个错误,查了半天才发 ...
- nginx+uwsgi+django
上一涨讲解了如何使用nginx+uwsgi部署wsgi application 其实django配置方式和 application都一样,因为如果我们对application进行扩展就是一个WSGI ...
- 常用 Linux 命令
Check page size: getconf PAGESIZE Check memory information: cat /proc/meminfo Check number of hugepa ...
- WebApp 中用 hashchange 做路由解析
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Oracle 精简绿色版客户端的配置
在项目开发中常常用到Oracle.但Oracle 客户端体积很大.安装后,主要用的就1个功能:TNS配置服务名,偶尔用到SqlPlus.在开发过程中,大量使用Navicate和PL/SQL Devel ...
- 大用处--PowerShell Management Library for Hyper-V.
http://pshyperv.codeplex.com/releases 用脚本来收集及集成HYPER-V管理. 越来越似KVM,LIBVIRT啦.
- centos6.5安装gcc6.1等c++环境
centos6.5安装gcc6.1等c++环境 1.获取gcc安装包并解压wget http://ftp.gnu.org/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.bz2tar ...
- HDNOIP201206施工方案
HDNOIP201206施工方案 难度级别:A: 运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 c国边防军在边境某处的阵地是由n个地堡组成的. ...