In our using Directives in AngularJS post we explained basics about the directives. Directives are used to add new attributes to the HTML tags. On the other Expressions in AngularJS are used for data-binding.

The syntax used for data-binding is {{ }}.

Let us consider the following example.

Name:

You wrote: {{ company }}

In this example the input field and data-binding done using ng-model are synchronized. Any data which we enter in out input field will be updated real-time on the page without the need to refresh it. In the above example we are using the ng-model to bind the input field to the data-binding expression using the variable name company.
We can also perform some mathematical operation inside the expressions. For example.

Name:

Total price is : {{ quantity * price }}

Related Posts

Leave a Reply