---
title: "How to use  ng-controller and ng-model in Angular JS?"  
description: "How to use  ng-controller and ng-model in Angular JS?"  
author: "Anupam Mishra"  
published: 2016-02-23  
updated: 2016-02-24  
canonical: https://www.mindstick.com/forum/33998/how-to-use-ng-controller-and-ng-model-in-angular-js  
category: "angular js"  
tags: ["javascript", "html", "angular js", "angularjs controller"]  
reading_time: 1 minute  

---

# How to use  ng-controller and ng-model in Angular JS?

Hi everyone,\
How to use ng-[controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) and ng-[model](https://yourviews.mindstick.com/view/81334/america-is-reopening-after-corona-lockdown-but-on-swedish-model) in [Angular](https://www.mindstick.com/articles/13081/advantages-disadvantages-of-angularjs-is-that-ideal-for-your-project) JS in [ASP.NET MVC](https://www.mindstick.com/forum/155798/what-is-caching-in-asp-dot-net-mvc) 4 .Please can [anyone give me](https://answers.mindstick.com/qa/41194/can-anyone-give-me-some-high-and-low-points-of-each-of-the-four-first-presidential-administrations) a solution .\
Thank you.

## Replies

### Reply by Manoj Bhatt

Here we have “**Customer**” controller which provides data via “**CustomerName**” and “**CustomerCode**” property and Add/ Update logic to save the data to database.“**Controllers**” are simple javascript function which provides data and logic to HTML UI. As the name says controller they control how data flows from the server to HTML UI.\

```
function Employee($scope){        $scope.FirstName = "Anupam";        $scope.EmployeeCode = "1001";        $scope.Add = function () {        }        $scope.Update = function () {        }}
```

\
“**ng-controller**” is a directive.Controllers are attached to the HTML UI by using the “**ng-controller**” directive tag and the properties of the controller are attached by using “**ng-model**” directive. For example below is a simple HTML UI which is attached to the “**Employee**” controller via the “**ng-controller**” directive and the properties are binded using “**ng-model**” directive.\

```
<div ng-controller="Employee"><input type=text id="FirstName"  ng-model="FirstName"/><br /><input type=text id="EmployeeCode"  ng-model="EmployeeCode"/></div>
```


---

Original Source: https://www.mindstick.com/forum/33998/how-to-use-ng-controller-and-ng-model-in-angular-js

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
