What is AngularJS Models





This article demonstrates nature and behavior of an AngularJS directive ng-model and starts with introduction of this directive. After that, we’ll understand it using  a set of examples. At last but not least, it’s two way behavior.

The ng-model Directive

The ng-model directive binds HTML control value to AngularJS application data. To implement this, we use a variable in AngularJS, which holds value of HTML element (input, select, textarea) in association with ng-model directive.

Let’s understand it with an example.

We have a text box  whose value is bound with AngularJS variable. In JavaScript, we’ll set value of text box using AngularJS APIs.

In the above example, we can see a text box, which is bound with AngularJS module “name”.

We created a reference to AngularJS application in JavaScript and set AngularJS variable “name” with the help of controller to “Satyendra Mishra”. This value is ultimately set as text box value.

Hence the output is as below:

Here, we have seen that if we set the value of AngularJS  model variable, it is automatically assigned to HTML element value.

 Two way behavior

It’s reverse is also possible. i.e.

If we set value of text box then provided value is automatically assigned to AngularJS model variable which can be fetched using AngularJs – Expression or ng-bind Directive.

Let’s see it’s example as well:

On page load, we’ll see  the output as below:

But as soon as we change value in text box, statement “Your name is ______” is also changed. See the screenshot below


In this article, I discussed about ng-model and it’s two way behavior. We learnt, how does data flow from HTML to AngularJS and vice versa.


Be  Connected…

Satyendra Mishra



THREE QUERIES offers easy access to information about SharePoint and associated technologies, project management, agile and scrum methodologies that helps developers, administrators, architects, technical managers, business analysts and end users. It has grown from there. We provide an important knowledge base for those involved in managing, architecture and developing software projects of all kinds. With weekly/daily exclusive updates, we keep you in touch with the latest business, management, technology thinking.

WE ARE CONNECTED ~ Follow us on social media to get regular updates and opinion on what's happening in the world of SharePoint, front-end, back end web technologies and project management. If you like this article, please share it and follow us at Facebook, Twitter, Instagram and LinkedIn

About Satyendra Mishra

Microsoft certified, motivated, energetic and accomplished SharePoint Consultant and Architect with 13+ years of work experience in Management, Architecture, Analytics, Development and Maintenance. He has been fortunate to be a part of over 20+ Web/Mobile/Software SharePoint and .Net projects delivery with various companies across different industry sectors. This has provided him a valuable insight and experience especially in successful implementation of technology solutions. Having very strong System Architecture, Technological, Management & Analytical Skills, Knowledge of Office 365, SharePoint, .Net, JavaScript, React, Angular, Azure, SQL. In 2016, he decided to start sharing the knowledge back to society in the form for content writing and blogging.
View all posts by Satyendra Mishra →

Leave a Reply

Your email address will not be published. Required fields are marked *