viewModel.attr vs. viewModel.get('attr')

2 posts, 0 answers
  1. Grant
    Grant avatar
    82 posts
    Member since:
    Jul 2016

    Posted 02 Oct Link to this post

    Hi, 

    When retrieving data from a model whats the difference between using "viewModel.attr" and "viewModel.get('attr')" ?

    Both return the same object.

    Thanks,
    Grant

  2. Tsvetina
    Admin
    Tsvetina avatar
    2087 posts

    Posted 04 Oct Link to this post

    Hello Grant,

    If you use viewModel.attr to access a value in a function inside the viewModel, on change of the attr value within the model, your function will not be re-evaluated.

    When a view model function accesses a value using the get() method, it gets notified on each value change and the function logic is re-evaluated (see dependent methods). If you use dot notation to access a value, you just get the current property value at the time of execution of this line of code.

    Additional information about the ObservableObject (view model) in Kendo MVVM is available here.

    Regards,
    Tsvetina
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top