one-way VS two-way data binding

One-Way Data Binding

ng-bindhasone-way data binding($scope --> view).

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

which displays the scope value$scope.myTextinserted into html wheremyTextis a variable name.

Two-Way Data Binding

ng-modelis intended to be put inside of form elements and hastwo-way data binding($scope --> view and view --> $scope) e.g.<inputname="firstname"ng-model="firstname"/>

When you interact with form elementfirstnamethatng-modelinteract with$scope.firstnameand update the corresponding view automatically by digest loop.

Last updated

Was this helpful?