The difference between ng-bind and ng-model
AngularJS data bindings include ng-bind and ng-model, which are generally used as follows:
<input ng-model="">
<span ng-bind=""></span>
ng-bind is a one-way binding that acts on $scope to the view layer and cannot be displayed in HTML controls (HTML controls include: input, select, button and textarea).
ng-model is a two-way binding, $scope<--->view layer.
{{}} is used to display data.
Complete code
<!DOCTYPE html> <html> <meta charset="utf-8"> <head> <style> div textarea{ background-color:yellow; } </style> <script src="/libs//1.4.6/"></script> </head> <body ng-app="myNoteApp"> <div class="aa" ng-controller="myNoteCtrl"> <h2>My Notes</h2> <p> <textarea ng-model="message" rows="10" cols="20" maxlength="100"> </textarea> </p> <p> <button ng-click="save()">save</button> <button ng-click="clear()">Clear</button> </p> <p>Number of characters left: <span ng-bind="left()"></span></p> <p>Number of characters left(method2): <span>{{leftvar}}</span></p> </div> <script> var app = ("myNoteApp",[]); ("myNoteCtrl",function($scope){ $ = ""; $ = 0; $ = function() {$ = 100 - $;return $;}; $ = function() {$ = "";}; $ = function() {alert("Note Saved");}; }); </script> </body> </html>
Thank you for reading, I hope it can help you. Thank you for your support for this site!