Angular 2 forms provide RxJS streams for you to work with the data and validity as it flows out of the forms. These streams allow you handle complex scenarios and asynchronous scenarios with relative ease. This example shows you how to log out the va…
Select Dropdowns in Angular 2 a built with select and option elements. You use *ngFor to loop through your values and create options and use ngModel to keep track of the value as it changes. <form #formRef="ngForm"> <select name="l…
Using Radio Buttons in Angular 2 requires a basic understanding of forms as well as how their labels will match up with each input. This lesson shows how to use *ngFor with radio buttons and covers the quirks of the id property and forattributes as w…
Forms in Angular 2 are essentially wrappers around inputs that group the input values together into an object and also check that all the inputs are valid. Angular 2 ‘sngForm allows you to get a reference to that object and validity and use them to d…
In this tutorial we are going to learn how we can also implement custom form field validation in Angular 2 template driven forms, by creating our own custom validation directive. We are going to see how to write such directive and how its a best prac…
Promise 是 ES 6 Async/Await 是 ES 7 Rxjs 是一个 js 库 在使用 angular 时,你会经常看见这 3 个东西. 它们都和异步编程有关,有些情况下你会觉得用它们其中任何一个效果都一样. 但又觉得好像哪里不太对.... 这篇就来说说,我在开发时的应用方式. 在 Typescript 还没有支持 Async/Await 的时候, angular 就已经发布了. 那时我们只想着 Promise vs Rxjs 这 2 者其实很好选择, 因为 "可读性"…
Angular 2’s ngModel exposes more than just validity, it even gives you the states of whether the input has been “touched” or changed. This lesson explains and compares those states so you can use them to make complex validity requirements. <form name…
Inputs using Angular 2’s ngModel automatically apply style classes of .ng-validand .ng-invalid each time the input’s validity changes. These classes allow you easily add your own styles simply by declaring the styles in your Componentdecorator. impor…
The ngModelGroup directive allows you to group together related inputs so that you structure the object represented by the form in a useful and predictable way. ngModelGroup is often used in combination with fieldset as they mostly represent the same…
Angular 2’s ngModel provides error objects for each of the built-in input validators. You can access these errors from a reference to the ngModel itself then build useful messaging around them to display to your users. First, you can use 'ngModel' fr…
RxJS 博大精深,看了好几篇文章都没有明白. 范围牵扯到了函数响应式开发去了... 我对函数式一知半解, 响应式更是第一次听到... 唉...不过日子还是得过...混着过先呗 我目前所理解的很浅, 大致上是这样的概念. 1.某些场景下它比promise好用, 它善于过滤掉不关心的东西. 2.它是观察者模式 + 迭代器模式组成的 3.跟时间,事件, 变量有密切关系 4.世界上有一种东西叫 "流" stream, 一个流能表示了一段时间里,一样东西发生的变化. 比如有一个值, 它在某段时…
You can load resource based on the url using the a combination of ActivatedRouteand Angular 2’s Http service. Since the params and Http are both streams, you can use RxJS to get the data off the param then switchMap over to an Http request using that…
参考连接?不如说是照搬链接.AngularJs官网地址快速起步地址. 对于一个一直只是用jq,偶尔学习点Knockout js,了解一点mvvm结构的前端来说,学习Angular2还是有点困难的.好了,废话少说.开始快速起步Demo案例的学习             首先选择一个编写前端代码的IDE.选择的有很多,比如SublimeText,JetBrains WebStorm等,我选择的是VsCode,这个更贴近我.一些智能提示,插件,对各个语言的支持比较广泛,当然开发AngularJs2也是…
From Article: RESOLVING ROUTE DATA IN ANGULAR 2 Github If you know Anuglar UI router, you must know resolve function in ui router, which you can load data before template and controller get inited. In Angular2 router, you can also use resovler. The r…
//switch-control component import { Component } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR, NG_VALIDATORS, Validators} from '@angular/forms'; @Component({ selector: 'switch-control', templateUrl: './switch-control.componen…
Splitting a stream into multiple streams causes new subscriptions. You can think of new subscriptions as "invoking a function". So if your original stream makes a request for data, splitting the original stream will make 2 requests for data. The…
The domStreams component property enables you to access Events from your Vue.js templates as Streams insides your subscriptions function. You can then map the Events to other values and stream them back into your Vue.js templates. <template> <sec…
Import module: import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { MessageComponent } from './message.component'; import messageRoutes from './message.routes'; import {FormsModule, ReactiveFormsModule} f…
<form [formGroup]="reactiveForm" novalidate autocomplete="off"> <div class="form-field"> <label>Title:</label> <input formControlName="title"> <div class="field-error-message&qu…
In this tutorial we are going to learn how simple it is to create custom form field driven validators while using Angular 2 model driven forms. These type of validators are really just plain functions that follow a set of conventions. We are going to…
最近项目中遇到一个表单input设置disabled问题,直接赋值angular原生的[disabled]=“isDisabled”无效,浏览器警告信息: 无奈,只能按照控制台提示修改: 问题解决…
Recompose provides helper functions to stream props using an Observable library of your choice into React. This lesson shows you how to configure Recompose to use RxJS then create a Streaming Component with Recompose’s componentFromStream helper func…
When easing isn’t enough to get the exact animation you want, you can leverage keyframes to define and precise styles and steps over time. Keyframes allow you to achieve pretty much any Angular 2 animation you want. animations:[ trigger('signal', [ s…
For each formBuild, formControl, formGroup they all have 'valueChanges' prop, which is an Observable. reactiveForm: FormGroup; video: Video; constructor(fb: FormBuilder) { this.reactiveForm = fb.group({ // title <-- formControlName="title" ti…
We can nest formGorup: this.reactiveForm = fb.group({ username: [ '', [ Validators.required, Validators.minLength() ] ], pwds: fb.group({ pwd: '', rpwd: '' }, {validator: passwordValidator}) }); We make password as an own group. So in html, we need t…
Learn how to create a custom validator to check whether passwords match. <h1>password match</h1> <form novalidate autocomplete="off" [formGroup]="signupForm"> <div class="form-field"> <label>Pass…
Learn how to update part of form model, full form model and reset whole form. We have form definetion like this: reactiveForm: FormGroup; constructor(fb: FormBuilder) { this.extra = new FormControl('...', [ Validators.maxLength() ]); this.reactiveFor…
<div class="form-field"> <label>Confirm Password: </label> <input type="text" formControlName="confirm" [(ngModel)]="signup.confirm" name="confrim"> <div *ngIf="!signupForm.…
Angular 4.x 中有两种表单: Template-Driven Forms - 模板驱动式表单 (类似于 AngularJS 1.x 中的表单 )  官方文档:https://v2.angular.cn/docs/ts/latest/guide/forms.html Reactive Forms (Model-Driven Forms) - 响应式表单  官方文档: https://v2.angular.cn/docs/ts/latest/guide/reactive-forms.htm…
先上效果页面:https://lpdong.github.io/myForm-1/ 其中几个知识点 1.angularJs提供了几个新的type类型: type="password" type="email" type="number" type="url" 2.几个参数含义 ng-required //是否必填,true/false ng-minlength //最小长度,数字 ng-maxlength //最大长度,数字…