top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between one-way binding and two-way binding in Angular js?

+2 votes
1,097 views
What is the difference between one-way binding and two-way binding in Angular js?
posted Jan 20, 2017 by Dhaval Vaghela

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

1 Answer

0 votes

One-Way Data Binding

ng-bind has one-way data binding ($scope --> view).

Eg.,  ng-bind="myText" OR {{ myText }}

which displays the scope value $scope.myText inserted into html where myText is a variable name.

Two-Way Data Binding

ng-model is intended to be put inside of form elements and has two-way data binding ($scope --> view and view --> $scope) e.g.

<input name="firstname" ng-model="firstname"/>

When you interact with form element firstname that ng-model interact with $scope.firstname and update the corresponding view automatically by digest loop.

answer Jan 24, 2017 by Manikandan J
...