-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade to support angular version 2.0.0-rc.5
- Loading branch information
1 parent
2dd9eaa
commit 843e598
Showing
8 changed files
with
120 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
import { bootstrap } from '@angular/platform-browser-dynamic'; | ||
import { disableDeprecatedForms, provideForms } from '@angular/forms'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
|
||
import { AppComponent } from './src/app.component'; | ||
import { AppModule } from './src/app.module'; | ||
|
||
bootstrap(AppComponent, [ | ||
disableDeprecatedForms(), | ||
provideForms(), | ||
]).catch(err => console.error(err)); | ||
platformBrowserDynamic().bootstrapModule(AppModule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { | ||
ValidatorFn, | ||
AbstractControl, | ||
Validators, | ||
FormGroup, | ||
REACTIVE_FORM_DIRECTIVES, | ||
FormControl | ||
} from '@angular/forms'; | ||
import { Validators, FormControl, FormGroup } from '@angular/forms'; | ||
|
||
import { CUSTOM_FORM_DIRECTIVES } from '../../src'; | ||
import { CustomValidators } from '../../src'; | ||
|
||
@Component({ | ||
selector: 'app', | ||
template: require('./app.html'), | ||
directives: [REACTIVE_FORM_DIRECTIVES, CUSTOM_FORM_DIRECTIVES] | ||
template: require('./app.html') | ||
}) | ||
export class AppComponent implements OnInit { | ||
rangeLength = [5, 6]; | ||
form: FormGroup; | ||
|
||
constructor() { | ||
} | ||
|
||
ngOnInit() { | ||
// this.form = new FormGroup({ | ||
// username: new FormControl('', Validators.compose([CustomValidators.number])) | ||
// }); | ||
var password = new FormControl('', Validators.required); | ||
var certainPassword = new FormControl('', CustomValidators.equalTo(password)); | ||
|
||
this.form = new FormGroup({ | ||
password: password, | ||
certainPassword: certainPassword | ||
}); | ||
} | ||
|
||
onSubmit(form) { | ||
console.log(form); | ||
onSubmit() { | ||
console.log(this.form); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,48 @@ | ||
<form #form="ngForm" (ngSubmit)="onSubmit(form)" novalidate> | ||
<h4>rangeLength</h4> | ||
<input type="text" ngModel name="username" #username="ngModel" [rangeLength]="[5, 9]" /> | ||
<p *ngIf="username?.errors?.rangeLength">rangeLength error</p> | ||
<form [formGroup]="form" (ngSubmit)="onSubmit()" novalidate> | ||
<!--<h4>rangeLength</h4>--> | ||
<!--<input type="text" ngModel name="username" #username="ngModel" [rangeLength]="[5, 9]" />--> | ||
<!--<p *ngIf="username?.errors?.rangeLength">rangeLength error</p>--> | ||
|
||
<h4>min</h4> | ||
<input type="text" ngModel name="min" #min="ngModel" [min]="5" /> | ||
<p *ngIf="min?.errors?.min">min error</p> | ||
<!--<h4>min</h4>--> | ||
<!--<input type="text" ngModel name="min" #min="ngModel" [min]="5" />--> | ||
<!--<p *ngIf="min?.errors?.min">min error</p>--> | ||
|
||
<h4>max</h4> | ||
<input type="text" ngModel name="max" #max="ngModel" [max]="9" /> | ||
<p *ngIf="max?.errors?.max">max error</p> | ||
<!--<h4>max</h4>--> | ||
<!--<input type="text" ngModel name="max" #max="ngModel" [max]="9" />--> | ||
<!--<p *ngIf="max?.errors?.max">max error</p>--> | ||
|
||
<h4>range</h4> | ||
<input type="text" ngModel name="range" #range="ngModel" [range]="[5, 9]" /> | ||
<p *ngIf="range?.errors?.range">range error</p> | ||
<!--<h4>range</h4>--> | ||
<!--<input type="text" ngModel name="range" #range="ngModel" [range]="[5, 9]" />--> | ||
<!--<p *ngIf="range?.errors?.range">range error</p>--> | ||
|
||
<h4>creditCard</h4> | ||
<input type="text" ngModel name="creditCard" #creditCard="ngModel" creditCard /> | ||
<p *ngIf="creditCard?.errors?.creditCard">creditCard error</p> | ||
<!--<h4>creditCard</h4>--> | ||
<!--<input type="text" ngModel name="creditCard" #creditCard="ngModel" creditCard />--> | ||
<!--<p *ngIf="creditCard?.errors?.creditCard">creditCard error</p>--> | ||
|
||
<h4>JSON</h4> | ||
<input type="text" ngModel name="json" #json="ngModel" json /> | ||
<p *ngIf="json?.errors?.json">JSON error</p> | ||
<!--<h4>JSON</h4>--> | ||
<!--<input type="text" ngModel name="json" #json="ngModel" json />--> | ||
<!--<p *ngIf="json?.errors?.json">JSON error</p>--> | ||
|
||
<h4>base64</h4> | ||
<input type="text" ngModel name="base" #base="ngModel" base64 /> | ||
<p *ngIf="base?.errors?.base64">base64 error</p> | ||
<!--<h4>base64</h4>--> | ||
<!--<input type="text" ngModel name="base" #base="ngModel" base64 />--> | ||
<!--<p *ngIf="base?.errors?.base64">base64 error</p>--> | ||
|
||
<h4>phone</h4> | ||
<input type="text" ngModel name="phone" #phone="ngModel" [phone]="'zh-CN'" /> | ||
<p *ngIf="phone?.errors?.phone">phone error</p> | ||
<!--<h4>phone</h4>--> | ||
<!--<input type="text" ngModel name="phone" #phone="ngModel" [phone]="'zh-CN'" />--> | ||
<!--<p *ngIf="phone?.errors?.phone">phone error</p>--> | ||
|
||
<h4>UUID</h4> | ||
<input type="text" ngModel name="uuid" #uuid="ngModel" [uuid]="4" /> | ||
<p *ngIf="uuid?.errors?.uuid">UUID error</p> | ||
<!--<h4>UUID</h4>--> | ||
<!--<input type="text" ngModel name="uuid" #uuid="ngModel" [uuid]="4" />--> | ||
<!--<p *ngIf="uuid?.errors?.uuid">UUID error</p>--> | ||
|
||
<h4>equal to "xxx"</h4> | ||
<input type="text" ngModel name="equal" #equal="ngModel" [equal]="'xxx'" /> | ||
<p *ngIf="equal?.errors?.equal">equal error</p> | ||
<!--<h4>equal to "xxx"</h4>--> | ||
<!--<input type="text" ngModel name="equal" #equal="ngModel" [equal]="'xxx'" />--> | ||
<!--<p *ngIf="equal?.errors?.equal">equal error</p>--> | ||
|
||
<h4>equalTo to password</h4> | ||
<input type="password" ngModel name="password" #password="ngModel"/> | ||
<input type="password" ngModel name="certainPassword" #certainPassword="ngModel" [equalTo]="password"/> | ||
<p *ngIf="certainPassword?.errors?.equalTo">equalTo error</p> | ||
<input type="password" formControlName="password"/> | ||
<p *ngIf="form.controls.password?.errors?.required">required error</p> | ||
<input type="password" formControlName="certainPassword"/> | ||
<p *ngIf="form.controls.certainPassword?.errors?.equalTo">equalTo error</p> | ||
<button>submit</button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { ReactiveFormsModule } from '@angular/forms'; | ||
|
||
import { AppComponent } from './app.component'; | ||
|
||
@NgModule({ | ||
imports: [BrowserModule, ReactiveFormsModule], | ||
declarations: [AppComponent], | ||
bootstrap: [AppComponent] | ||
}) | ||
export class AppModule { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters