O'Reilly logo

Mastering Web Application Development with AngularJS by Pawel Kozlowski, Peter Bacon Darwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding directive controllers

A controller in AngularJS is an object attached to a DOM element that initializes and adds behaviour to the scope at that element.

Note

We have already seen many application controllers, instantiated by the ng-controller directive. These controllers should not interact directly with the DOM but should deal only with the current scope.

A directive controller is a special form of controller that is defined by a directive and instantiated each time that directive appears on a DOM element. Its role is to initialize and provide behavior for the directive rather than a scope.

You define a directive controller using the controller property on the directive definition object. The controller property can be a string containing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required