Open In App

AngularJS ng-non-bindable Directive

Last Updated : 08 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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. 

HTML




<!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>
    <h3>ng-non-bindable Directive</h3>
    <div>
        The result of
              <span ng-non-bindable
                  style="background-color:green;
                         color:white">
                  {{5+5}}
              </span> is {{5+5}}
    </div>
</body>
</html>


Output:

 

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

HTML




<!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>
    <h3>ng-non-bindable Directive</h3>
    <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:

 



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads