June 2014
Intermediate to advanced
696 pages
38h 52m
English
You can add a custom controller to a directive by using the controller property of the directive definition. This allows you to provide controller support for the directive template. For example, the following code adds a simple controller that sets up a scope value and function:
directive('myDirective', function() { return { scope: {title: '='}, controller: function ($scope){ $scope.title = "new"; $scope.myFunction = function(){ }); } };});
You can also use the require option to ensure that a controller is available to the directive. The require option uses the require:'^controller' syntax to instruct the injector service to look in parent contexts until ...
Read now
Unlock full access