导入表单模块

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. NGUI实现UITexture的UV滚动

    材质上使用的贴图: 效果:实现该纹理在屏幕上的滚动 代码: using System.Collections; using System.Collections.Generic; using Unit ...

  2. shell和shell脚本基本知识

    详情可见: https://www.cnblogs.com/yinheyi/p/6648242.html 这张图,可以帮助我们理解这个词语! 最底下是计算机硬件,然后硬件被系统核心包住,在系统核心外层 ...

  3. python中文件的读和写操作

    一.打开文件 data = open("yesterday",encoding="utf-8").read() # python默认的打字符编码是unicode ...

  4. ThinkPHP的数据操作

    查询: 具体数据的操作方法使用: 1. where()条件     $model->where(条件值);  //条件值就是sql语句where后边的结果值 2. limit() 限制条数  $ ...

  5. spring cloud: Hystrix(六):feign的注解@FeignClient:fallbackFactory(类似于断容器)与fallback方法

    fallbackFactory(类似于断容器)与fallback方法 feign的注解@FeignClient:fallbackFactory与fallback方法不能同时使用,这个两个方法其实都类似 ...

  6. mismatch详解

    mismatch到底只是一个碱基替换,还是也包括了插入缺失? If two sequences in an alignment share a common ancestor, mismatches ...

  7. English trip V1 - B 18. Workplaces 工作地方 Teacher:Russell Key: do / does

    In this lesson you will learn to talk about workplaces. 课上内容(Lesson) My English Teacher name is Russ ...

  8. layui 导出表格数据

    第一种方法没试过,有机会要试试.

  9. pip安装kolla-ansible时报错Cannot install 'PyYAML'的解决方法

    pip install kolla-ansible --ignore-installed PyYAML

  10. consul总结

    一.介绍 内置了服务注册与发现框 架.分布一致性协议实现.健康检查.Key/Value存储.多数据中心方案,不再需要依赖其他工具(比如ZooKeeper等)服务部署简单,只有一个可运行的二进制的包.每 ...