Get value from textfield


I’m a beginner in native script.
I made a login page and when I click in the submit button I want to get the user value in the textfield pseudo and password.
But I don’t know how to make that.
This is my code :

            <TextField id="pseudo"></TextField>

            <TextField  id="password"></TextField>

    <Button (tap)="login()"></Button>

Could you help me please ?


Are you using Angular / Core? If it’s core your syntax for tap event is wrong. If it’s Angular, you don’t have to include Page element, its created automatically when you use page router outlet.

I suggest you to go though the respective getting started guide.


I use angular and native script with typescript language.
Ok for the Page, I will change that.
But the problem is not resolve.
Could you see me a simple example because I search since a week to find a solution but I don’t find ?


If you know how to do this in Angular, it’s just the same with NativeScript. Use noModel / FormGroup / simply assign angular id and use ViewChild directive to get the element and it’s value from there.


No, you can’t use document.getelementById(), that’s not a Angular api but browser specific.

Besides getViewById() is an equivalent to getelementById() in NativeScript environment.


You can use Page.getViewById(“pseudo”).text, if you haven’t gone through the getting started guide yet, I would encourage you to do that at earliest to get some heads up on basics.