Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Getting Started with NativeScript

You're reading from   Getting Started with NativeScript Explore the possibility of building truly native, cross-platform mobile applications using your JavaScript skill—NativeScript!

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher
ISBN-13 9781785888656
Length 168 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Nathanael J. Anderson Nathanael J. Anderson
Author Profile Icon Nathanael J. Anderson
Nathanael J. Anderson
Arrow right icon
View More author details
Toc

Binding


Binding is what allows us to do <Edit value="{{ message }}"> in the Declarative UI and have it automatically update the edit value when the message value changes. The Bindable component handles all the binding and the callbacks for any bindable properties.

Using binding is actually simple. You need a source object, in this case, the message variable. You need the component itself, so again, in this example, the Edit component. Then, you just use the bind method on the Edit component to bind the source object to itself. Likewise, if you need to unbind, you would use the method named unbind.

The final property of the Bindable component is bindingContext, which is used to set the primary Observable object of the component and its children. If you recall in the prior chapter, the main-page.js file executed page.bindingContext = vmModule.mainViewModel. This code sets the page's bindingContext to the Observable object the mainViewModel file exported. This is needed so that the two...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images