Full Name: {{firstName + " " + lastName}}
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
[Try it Β»](#)
* * *
## Definition and Usage
The **ng-controller** directive adds a controller to your application.
In the controller, you can write code, make functions and variables, and use the scope object to access them.
* * *
## Syntax
Supported by all HTML elements.
* * *
## Parameter Values
| Value | Description |
| --- | --- |
| _expression_ | The controller name. |
* * AngularJS Reference](#)Ng Ng Controller
# AngularJS `ng-controller` Directive
[ AngularJS Reference](#)
* * *
## AngularJS Example
Add a controller to an application variable:
YouTip