YouTip LogoYouTip

Ng Ng Controller

# AngularJS `ng-controller` Directive [![Image 3: AngularJS Reference](#) AngularJS Reference](#) * * * ## AngularJS Example Add a controller to an application variable:
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](#)
← Sass NestingSass Install β†’