From c34cb0140406231ab37f68322576039bc9cea929 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Sat, 13 Jun 2015 12:15:54 -0700 Subject: [PATCH] fix(forms): updated form examples to contain select elements --- .../examples/src/model_driven_forms/index.ts | 22 +++++++++++++++++-- .../src/template_driven_forms/index.ts | 22 +++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/modules/examples/src/model_driven_forms/index.ts b/modules/examples/src/model_driven_forms/index.ts index 000b1d5619..e9d8c4899f 100644 --- a/modules/examples/src/model_driven_forms/index.ts +++ b/modules/examples/src/model_driven_forms/index.ts @@ -1,4 +1,13 @@ -import {bootstrap, onChange, NgIf, Component, Directive, View, Ancestor} from 'angular2/angular2'; +import { + bootstrap, + onChange, + NgIf, + NgFor, + Component, + Directive, + View, + Ancestor +} from 'angular2/angular2'; import {formDirectives, NgControl, Validators, NgFormModel, FormBuilder} from 'angular2/forms'; import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang'; @@ -86,6 +95,13 @@ class ShowError {

+

+ + +

+

@@ -113,16 +129,18 @@ class ShowError { `, - directives: [formDirectives, ShowError] + directives: [formDirectives, NgFor, ShowError] }) class ModelDrivenForms { form; + countries = ['US', 'Canada']; constructor(fb: FormBuilder) { this.form = fb.group({ "firstName": ["", Validators.required], "middleName": [""], "lastName": ["", Validators.required], + "country": ["Canada", Validators.required], "creditCard": ["", Validators.compose([Validators.required, creditCardValidator])], "amount": [0, Validators.required], "email": ["", Validators.required], diff --git a/modules/examples/src/template_driven_forms/index.ts b/modules/examples/src/template_driven_forms/index.ts index 54beef4a12..1345e0141b 100644 --- a/modules/examples/src/template_driven_forms/index.ts +++ b/modules/examples/src/template_driven_forms/index.ts @@ -1,4 +1,13 @@ -import {bootstrap, onChange, NgIf, Component, Directive, View, Ancestor} from 'angular2/angular2'; +import { + bootstrap, + onChange, + NgIf, + NgFor, + Component, + Directive, + View, + Ancestor +} from 'angular2/angular2'; import {formDirectives, NgControl, Validators, NgForm} from 'angular2/forms'; import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang'; @@ -13,6 +22,7 @@ class CheckoutModel { firstName: string; middleName: string; lastName: string; + country: string = "Canada"; creditCard: string; amount: number; @@ -107,6 +117,13 @@ class ShowError {

+

+ + +

+

@@ -134,10 +151,11 @@ class ShowError { `, - directives: [formDirectives, CreditCardValidator, ShowError] + directives: [formDirectives, NgFor, CreditCardValidator, ShowError] }) class TemplateDrivenForms { model = new CheckoutModel(); + countries = ['US', 'Canada']; onSubmit() { print("Submitting:");