How to Bind data in AngulaJS?

Two way data binding will be available when a model variable is bound to a HTML element which can display and change the value of the variable. Same variable can be bound to multiple HTML elements.

We use ng-model directive to bind a model variable to one or more HTML elements, which can display and also update the value.

In below example, we bind the firstName and lastName model variables to a couple of HTML input elements. When the page is loaded, the value of the input elements are initialized to those of the respective model variables and whenever the user types something in an input, the value of the model variable is modified as well (two way).