From the course: Building Native Mobile Apps with NativeScript and Angular 2

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Event binding

Event binding - JavaScript Tutorial

From the course: Building Native Mobile Apps with NativeScript and Angular 2

Start my 1-month free trial

Event binding

- [Instructor] We've seen a few examples of event binding in action in the chapter on user interface in the gesture's lesson. UI elements in NativeScript have a few events that we can bind to, but, by far, the most common UI event you'll bind to in a mobile application is the tap event. Instead of the square brackets, event binding uses parenthesis surrounding the event name that you want to bind. For the value part of the binding, you specify a function call including any parameters you want to pass the function. Let's take a look at the login page so we can play around with the tab function. Make sure to change the child component of the app component to pt login. That way we can see the login page here in the emulator. Let's open up the pt login component TypeScript and the HTML files. Our login button has a tap even attached and it signifies that we should use the login handler to handle the event. I'll temporarily call a different handler, we'll call it loginTapped, so we can see…

Contents