10000 feat($compile): add custom annotations to the controller by petebacondarwin · Pull Request #14114 · angular/angular.js · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat($compile): add custom annotations to the controller #14114

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat($compile): add custom annotations to the controller
This means that we can access these annotations, such as
`$routeConfig` and `$routerCanActivate` without highjacking
the `ng` module.
  • Loading branch information
petebacondarwin committed Feb 23, 2016
commit 25213fb569e5ca885128a766450d5f48306b7dc9
1 change: 1 addition & 0 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
forEach(options, function(val, key) {
if (key.charAt(0) === '$') {
factory[key] = val;
controller[key] = val;
}
});

Expand Down
16 changes: 16 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10044,6 +10044,22 @@ describe('$compile', function() {
}));
});

it('should add additional annotations to the controller constructor', function() {
var myModule = angular.module('my', []).component('myComponent', {
$canActivate: 'canActivate',
$routeConfig: 'routeConfig',
$customAnnotation: 'XXX'
});
module('my');
inject(function(myComponentDirective) {
expect(myComponentDirective[0].controller).toEqual(jasmine.objectContaining({
$canActivate: 'canActivate',
$routeConfig: 'routeConfig',
$customAnnotation: 'XXX'
}));
});
});

it('should return ddo with reasonable defaults', function() {
angular.module('my', []).component('myComponent', {});
module('my');
Expand Down
0