Ng-Bind-2

 

Let us understand "ng-bind" with the example of addition of two numbers, In this example, We are taking two variables val1 and val2 and assigning them 5 and 3 as $scope.val1 = 5; $scope.val2 = 3; We want to show addition of these numbers in span tag and here is how we use "Ng-bind" ng-bind="val1+val2"

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="myApp"> <div ng-controller="myController"> <b>Sum:</b> <span ng-bind="val1+val2"></span> </div> <script> var app = angular.module("myApp", []); app.controller('myController', ['$scope', function ($scope) { $scope.val1 = 5; $scope.val2 = 3; }]); </script> </body> </html>
Output