AngularJS | ng-non-bindable Directive
The ng-non-bindable Directive in AngularJS is used to specify that the specific content of HTML should not be compiled i.e the contents should be ignored by AngularJS. It can be used when we want to display code snippets instead of compiled output.
Syntax:
<element ng-non-bindable> Contents... </element>
Example 1: This example uses ng-non-bindable Directive to ignore expression.
<!DOCTYPE html> <html> <head> <title>ng-non-bindable Directive</title> <script src= </script> </head> <body ng-app="" style="text-align: center"> <h1 style="color:green">GeeksforGeeks</h1> <h2>ng-non-bindable Directive</h2> <div> The result of <span style="background-color:green;color:white" ng-non-bindable>{{5+5}}</span> is = {{5+5}} </div> </body> </html> |
Output:

Example 2: This example uses ng-non-bindable Directive to ignore expression.
<!DOCTYPE html> <html> <head> <title>ng-non-bindable Directive</title> <script src= </script> </head> <body ng-app="app" style="text-align: center"> <h1 style="color:green">GeeksforGeeks</h1> <h2>ng-non-bindable Directive</h2> <div ng-controller="geek"> Input 1: <input type="number" ng-model="val1" /> <br><br> Input 2: <input type="number" ng-model="val2" /> <br><br> <input type="button" value="sum" ng-click="sum()" /> <br><br> <div>Without Non-Bindable: {{result}}</div> <div ng-non-bindable>With Non-Bindable: {{result}}</div> </div> <script> var app = angular.module("app", []); app.controller('geek', ['$scope', function ($scope) { $scope.sum = function () { $scope.result = $scope.val1 + $scope.val2; } }]); </script> </body> </html> |
Output:
Before Click:

After Click:

Recommended Posts:
- AngularJS | ng-cut Directive
- AngularJS | ng-app Directive
- AngularJS | ng-value Directive
- AngularJS | ng-if Directive
- AngularJS | ng-src Directive
- AngularJS | ng-csp Directive
- AngularJS | Directive
- AngularJS | ng-jq Directive
- AngularJS | ng-srcset Directive
- AngularJS | ng-readonly Directive
- AngularJS | ng-paste Directive
- AngularJS | ng-required Directive
- AngularJS | input Directive
- AngularJS | ng-selected Directive
- AngularJS | ng-options Directive
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



