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.



filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>                    

chevron_right


Output:
ngnonbindable

Example 2: This example uses ng-non-bindable Directive to ignore expression.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>                    

chevron_right


Output:
Before Click:
ngnonbindable
After Click:
ngnonbindable



My Personal Notes arrow_drop_up


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.