This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
example in docs for $controller appears wrong #12550
Closed
Description
The docs for ngMock.$controller
give an example of it's invocation as
myMod.directive('myDirective', {
controller: 'MyDirectiveController',
bindToController: {
name: '@'
}
});
// Controller definition ...
myMod.controller('MyDirectiveController', ['log', function($log) {
$log.info(this.name);
})];
Then,
$controller('MyDirective', { /* no locals */ }, { name: 'Clark Kent' })
But 'MyDirective' is the registered name of the directive, not the controller. Nowhere in the docs for $controller does it say that $controller will look up a controller by the name of a directive that binds to it. Is this a mistake in the docs?