Skip to content
Related Articles

Related Articles

AngularJS | Expressions
  • Last Updated : 27 Mar, 2019

Expressions in AngularJS are used to bind application data to HTML. The expressions are resolved by Angular and the result is returned back to where the expression is written. The expressions in AngularJS are written in double braces: {{ expression }}. They behave similar to ng-bind directives: ng-bind=”expression”.
Syntax:

{{ expression }}

Example: This example displays the name that we feed in the ng-init directive.




<!DOCTYPE html>
<html>
    angular.min.js"></script>
    <head>
        <title>AngularJS Introduction</title>
    </head>
    <body style = "text-align:center">
            <h2 style = "color:green">AngularJS Expressions</h2>
            <div ng-app="" ng-init="name='GeeksforGeeks'">
            <p> {{ name }} is a portal for geeks.</p>
            </div>
    </body>
</html>

Output:
expression

Example 2: This example displays the content of the object that we feed in ng-init directive.




<html>
    angular.min.js"></script>
    <head>
        <title>AngularJS Introduction</title>
    </head>
    <body>
        <h2 style = "color:green">AngularJS Expressions</h2>
        <div ng-app="" ng-init="sort={one:'quick sort',
        two:'merge sort', three:'bubble
            sort'}">
            <p> Sorting Algorithms:
            <ul>
                <li>{{ sort.one }}</li>
                <li>{{ sort.two }}</li>
                <li>{{ sort.three }}</li>
            </ul>
        </div>
    </body>
</html>

Output:
expression




My Personal Notes arrow_drop_up
Recommended Articles
Page :