AngularJS
supports both one-way and two-way data binding between the model
and the view, depending on the need one can use any one of these bindings. As
the name suggests one-way data binding is unidirectional the data from the
model is bound to the view and not vice versa. The ng-bind directive enables one-way
data binding
The ng-bind directive provides one way binding between the model and the View, and changes made in the view will not be reflected in the model. The ng-bind directive is similar to using expressions {{ expression }} in AngularJS.
The below example shows a simple implementation of ng-bind to achieve one way data binding between the model and the view.
<html ng-app>
<head>
<meta charset="utf-8" />
<title>AngularJS - Basic</title>
<script src="angular.min.js"></script>
</head>
<body>
<div ng-init="Name='FirstName, LastName'">
Your Name is: <span type="text" ng-bind="Name"></span><br/><br/>
</div>
</body>
</html>
Output
The ng-bind directive provides one way binding between the model and the View, and changes made in the view will not be reflected in the model. The ng-bind directive is similar to using expressions {{ expression }} in AngularJS.
The below example shows a simple implementation of ng-bind to achieve one way data binding between the model and the view.
<html ng-app>
<head>
<meta charset="utf-8" />
<title>AngularJS - Basic</title>
<script src="angular.min.js"></script>
</head>
<body>
<div ng-init="Name='FirstName, LastName'">
Your Name is: <span type="text" ng-bind="Name"></span><br/><br/>
</div>
</body>
</html>
Output
No comments:
Post a Comment