This is a migrated thread and some comments may be shown as answers.

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

1 Answer 48 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
Grant asked on 02 Oct 2017, 01:26 PM

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

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 04 Oct 2017, 10:21 AM
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.
Tags
MVVM
Asked by
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Tsvetina
Telerik team
Share this question
or