AngularJS | Expressions

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:
expression

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

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:
expression



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.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.