Categories: AngularJs

Expressions – AngularJS

AngularJS expressions contain operators,literals, and variables.

AngularJS expressions can be written inside HTML while JavaScript expressions can’t be.

AngularJS expressions do not support conditionals, loops, and exceptions.

AngularJS expressions support filters.

Expressions are written inside double curly braces. They contain variables, literals and operators.
For example: {{exp}}
{{23-19}} , {{11+89}}, {{stateName +’ ‘+cityName}}

[html]

Expression sum: {{ 23 + 2 }}



[/html]

ng-bind:
ng-bind directive can be used to bind the innerHTML to the value returned from an expression.

Example without ng-bind:

[html]

Result: {{ a * b }}

[/html]

Example using ng-bind:

[html]

[/html]

Strings can also be used the same way:

Example without ng-bind:

[html]

Result: {{ a +’ ‘+ b }}

[/html]

Example using ng-bind:

[html]

[/html]

Example Objects without ng-bind:

[html]

Result: {{ place.city +’ ‘+ place.state }}

[/html]

Example Objects using ng-bind:

[html]

[/html]

Arrays without ng-bind:

<div ng-app=”” ng-init=”place=[‘Agra’,’Delhi’]”>
<p>Result: {{ place[0] +' '+ place[1] }}

Arrays using ng-bind:

<div ng-app=”” ng-init=”place=['Agra','Delhi']”>
<p ng-bind=”place[0] +' '+ place[1]”>

jeff77

Disqus Comments Loading...

Recent Posts

Noun

A Noun is the name of a person, place or thing. or Name of anything is noun. For example: Sita…

10 years ago

Introduction – AngularJS

Misko Hevery, a Google employee, developed AngularJS. First version 1.0 of AngularJS was released in 2012. Now AngularJS is fully…

9 years ago

Noun – Exercise

Some sentences are given below. Choose the nouns and mention the type of noun whether they are proper noun, common…

9 years ago

Modules – AngularJS

Modules are containers for appication controller. They contain different parts of an application. [html] {{ state + " " +…

9 years ago

Directives – AngularJS

Using Directives you can extend HTML attributes. In AngularJS you can define your own directives while it has its own…

9 years ago

Choose a Quiz

English Quizzes: English Noun Quiz – Set 1 English Noun Quiz – Set 2

9 years ago