导入表单模块

import { FormsModule } from '@angular/forms';
// ...
@NgModule({
imports: [BrowserModule, FormsModule],
declarations: [AppComponent, UserComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
模板变量语法

<video #player></video>
<button (click)="player.pause()">Pause</button> <video #player></video> ==
<video ref-player></video>示例;
@Component({
selector: 'sl-user',
template: `
...
<div>
<form (submit)="addSkill(skill.value)">
<label>添加技能</label>
<input type="text" #skill>
</form>
</div>
`
})
export class UserComponent {
// ...
  skills: string[];
  constructor() {
this.skills = ['AngularJS 1.x', 'Angular 2.x', 'Angular 4.x'];
}
    addSkill(skill: string) {
let skillStr = skill.trim();
if (this.skills.indexOf(skillStr) === -) {
this.skills.push(skillStr);
}
}
}

angular4-表单的更多相关文章

  1. Angular4 表单处理

  2. angularcli 第五篇(输入框、表单处理)

    本文参考:Angular4 表单快速入门 注:涉及input表单时要在AppComponent中引入 FormsModule模块:     import{ FormsModule } from '@a ...

  3. Angular4.x 创建组件|绑定数据|绑定属性|数据循环|条件判断|事件|表单处理|双向数据绑定

    Angular4.x 创建组件|绑定数据|绑定属性|数据循环|条件判断|事件|表单处理|双向数据绑定 创建 angular 组件 https://github.com/angular/angular- ...

  4. Angular4——7.表单处理

    在Angular中存在两种表单处理方式: 模版驱动式表单 表单的数据模型是通过组件模版中的相关指令来定义的.由于使用这种方式定义表单的数据模型时,我们会受限于HTML的语法,所以,模版驱动方式只适用于 ...

  5. Angular4笔记——表单状态相关的属性

    表单状态字段(FromControl)touched和untouched用来判断用户是否访问过一个字段(也就是这个字段是否获取过焦点,如果获取过焦点,touched是true,untouched是fa ...

  6. angular4 form表单验证

    <!-- novalidate 清除浏览器默认的校验行为 --> <form [formGroup]="formModel" (ngSubmit)="o ...

  7. angular4 自定义表单验证Validator

    表单的验证条件有时候满足不了需求就可以自定义验证 唯一要求返回是ValidatorFn export interface ValidatorFn{ (c:AbstractControl):Valida ...

  8. angular4 自定义表单组件

    自定义表单组件分为单值组件和多值组件. 单值组件:input/select/radio/textarea 多值组件:checkbox/tree组件 条件: 1.必须实现ControlValueAcce ...

  9. angular4 Form表单相关

    ng4中,有两种方式去声明一个表单 一:Template-Driven Forms - 模板驱动式表单   [引入FormsModule] 1.ngForm赋值 [可以方便的获取表单的值] <f ...

  10. Angular2 表单验证相关

    angular4响应式表单与校验http://blog.csdn.net/xiagh/article/details/78360845?locationNum=10&fps=1 How to ...

随机推荐

  1. css无定宽水平居中

    转载:http://www.cnblogs.com/jogen/p/5213566.html 这个博客的菜单ui还是棒棒的. 方法一 思路:显示设置父元素为:table,子元素为:cell-table ...

  2. 输出图片格式BARTENDER

    try {                BarTender.Application btApp = new BarTender.Application();                BarTe ...

  3. Windows的空格预览神器 | QuickLook

    用惯了Mac,发现空格预览真的能极大的提升效率和手感. QuickLook,Windows版的空格预览神器,效果差一些,速度有点慢,勉强用吧.

  4. spring ----> aop的两种实现方式

    实现1:基于xml package com.rr.spring3.interf; //接口 public interface SayHello { public void sayHello(); } ...

  5. English trip EM2-PE-6A Family Relationship Teacher:Taylor

    课上内容(Lesson) What's your name? Where is your hometown?  你的家乡是哪里? Where do you come from?    你从哪里来?  ...

  6. php中Redis的扩展

    首先要下载 php_redis.dll 和 php_igbinary.dll 在官网(https://windows.php.net/downloads/pecl/snaps/redis/3.1.4/ ...

  7. 网络管理命令ping和arping

    ping ping        向目标主机发送icmp请求包 常用来测试当前主机与目标主机网络连接状况 常见选项 -c              设置发包的个数 -s               设 ...

  8. 373. Find K Pairs with Smallest Sums (java,优先队列)

    题目: You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Def ...

  9. SQL SERVER 子查询使用Order By;按In排序

    [子查询]使用order by percent * from table order by id) a 这时发现结果没有按id排序,需要将100 percent 改成 99.999 percent 或 ...

  10. shiro中记住我功能

    Shiro提供了记住我(RememberMe)的功能,比如访问如淘宝等一些网站时,关闭了浏览器下次再打开时还是能记住你是谁,下次访问时无需再登录即可访问,基本流程如下: 1.首先在登录页面选中Reme ...