0

I'm trying kendo ui's (Ver.RC0) NumericTextBoxComponent for angular2 but on the api there is no mention about the component attribute "formControlName".

I'd like to do something like this to validate the form control in the FormGroup:

<kendo-numerictextbox [value]="myvalue" 
                      formControlName ="myNumericFieldFormControl"
                      >
</kendo-numerictextbox>

Is this possible? If yes, how?

Carlo Luther
  • 2,402
  • 7
  • 46
  • 75

1 Answers1

0

It seems to work in the documentation:

http://www.telerik.com/kendo-angular-ui/components/inputs/numerictextbox/#toc-form-support

   @Component({
       selector: 'my-app',
       template: `
           <h4>Only values between -10 and 20 are valid</h4>
           <form [formGroup]="form">
               <kendo-numerictextbox formControlName="numeric" [min]="-10" [max]="20"></kendo-numerictextbox> <br />
               <p *ngIf="form.controls.numeric.errors">{{form.controls.numeric.errors | json}}</p>
           </form>
       `
   })
   export class AppComponent {
       public form: FormGroup;
       constructor(private formBuilder: FormBuilder) {
           this.form = this.formBuilder.group({
               numeric: [20]
           });
       }
   }

Here is a runnable plunker demo: http://plnkr.co/edit/FlTfasHq8wvRBzCsWbOK?p=preview

George K
  • 1,763
  • 1
  • 9
  • 17