Can't change `setInputType` to TextField?


#1

I have this markup XML :

<TextField [(ngModel)]="user"  hint="user" #a  id="a"></TextField>

Inside the class I have :

@ViewChild('a') someInput: ElementRef;

But when I do this : (Inside : ngOnInit())

   this.page.getViewById< TextField>("a")
                  .android
                  .setInputType(android.text.InputType.TYPE_CLASS_DATETIME  );

I get :

ERROR TypeError: Cannot read property ‘setInputType’ of undefined

What am I missing ?

(I already know I can do it via keyboard type attribute in markup , But I want to do it imperative).


#2

@Royi_Namir The native view for android is not yet created during ngOnInit. Try running the same code in loaded event of text field or may be a simple timeout can also help.