top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why one-way data binding is introduced?

0 votes
305 views
Why one-way data binding is introduced?
posted Oct 23, 2017 by Jayshree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

In order to make data-binding possible, Angular uses $watch APIs to observe model changes on the scope.
Angular registered watchers for each variable on scope to observe the change in its value. If the value, of variable
on scope is changed then the view gets updated automatically.
This automatic change happens because of $digest cycle is triggered. Hence, Angular processes all registered
watchers on the current scope and its children and checks for model changes and calls dedicated watch listeners
until the model is stabilized and no more listeners are fired. Once the $digest loop finishes the execution, the
browser re-renders the DOM and reflects the changes.
By default, every variable on a scope is observed by the angular. In this way, unnecessary variable are also
observed by the angular that is time consuming and as a result page is becoming slow.
Hence to avoid unnecessary observing of variables on scope object, angular introduced one-way data binding.

answer Oct 23, 2017 by Shivaranjini
...