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

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

    Posted 02 Oct 2017 Link to this post


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

    Both return the same object.


  2. Answer
    Tsvetina avatar
    2481 posts

    Posted 04 Oct 2017 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.

    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