top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Explain Two-way and One-way data binding in AngularJS?

0 votes
471 views
Explain Two-way and One-way data binding in AngularJS?
posted Oct 23, 2017 by Jayshree

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

1 Answer

0 votes

Two-way data binding - It is used to synchronize the data between model and view. It means, any change
in model will update the view and vice versa. ng-model directive is used for two-way data binding.
One-way data binding - This binding is introduced in Angular 1.3. An expression that starts with double colon (::),
is considered a one-time expression i.e. one-way binding.
Two-Way and One-Way data binding Example

<div ng-controller="MyCtrl">
 <label>Name (two-way binding): <input type="text" ng-model="name" /></label>
 <strong>Your name (one-way binding):</strong> {{::name}}<br />
 <strong>Your name (normal binding):</strong> {{name}}
</div>
<script>
 var app = angular.module('app', []);
 app.controller("MyCtrl", function ($scope) {
 $scope.name = "Shailendra Chauhan"
 })
</script>
answer Oct 23, 2017 by Shivaranjini
...