Skip to content
Related Articles

Related Articles

Improve Article

AngularJS | ng-non-bindable Directive

  • Last Updated : 28 Mar, 2019
Geek Week

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:
ngnonbindable

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:
ngnonbindable
After Click:
ngnonbindable




My Personal Notes arrow_drop_up
Recommended Articles
Page :