This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +18
-6
lines changed
2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -1106,7 +1106,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1106
1106
}
1107
1107
1108
1108
var template = ( ! options . template && ! options . templateUrl ? '' : options . template ) ;
1109
- return {
1109
+ var ddo = {
1110
1110
controller : controller ,
1111
1111
controllerAs : identifierForController ( options . controller ) || options . controllerAs || '$ctrl' ,
1112
1112
template : makeInjectable ( template ) ,
@@ -1117,8 +1117,18 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1117
1117
restrict : 'E' ,
1118
1118
require : options . require
1119
1119
} ;
1120
+
1121
+ // Copy annotations (starting with $) over to the DDO
1122
+ forEach ( options , function ( val , key ) {
1123
+ if ( key . charAt ( 0 ) === '$' ) ddo [ key ] = val ;
1124
+ } ) ;
1125
+
1126
+ return ddo ;
1120
1127
}
1121
1128
1129
+ // TODO(pete) remove the following `forEach` before we release 1.6.0
1130
+ // when the router no longer looks for the annotations on the controller
1131
+
1122
1132
// Copy any annotation properties (starting with $) over to the factory function
1123
1133
// These could be used by libraries such as the new component router
1124
1134
forEach ( options , function ( val , key ) {
Original file line number Diff line number Diff line change @@ -10493,15 +10493,15 @@ describe('$compile', function() {
10493
10493
} ) ) ;
10494
10494
} ) ;
10495
10495
10496
- it ( 'should add additional annotations to the controller constructor ' , function ( ) {
10496
+ it ( 'should expose additional annotations on the directive definition object ' , function ( ) {
10497
10497
var myModule = angular . module ( 'my' , [ ] ) . component ( 'myComponent' , {
10498
10498
$canActivate : 'canActivate' ,
10499
10499
$routeConfig : 'routeConfig' ,
10500
10500
$customAnnotation : 'XXX'
10501
10501
} ) ;
10502
10502
module ( 'my' ) ;
10503
10503
inject ( function ( myComponentDirective ) {
10504
- expect ( myComponentDirective [ 0 ] . controller ) . toEqual ( jasmine . objectContaining ( {
10504
+ expect ( myComponentDirective [ 0 ] ) . toEqual ( jasmine . objectContaining ( {
10505
10505
$canActivate : 'canActivate' ,
10506
10506
$routeConfig : 'routeConfig' ,
10507
10507
$customAnnotation : 'XXX'
@@ -10515,9 +10515,11 @@ describe('$compile', function() {
10515
10515
controller : 'SomeNamedController'
10516
10516
} ) ;
10517
10517
module ( 'my' ) ;
10518
- expect ( function ( ) {
10519
- inject ( function ( myComponentDirective ) { } ) ;
10520
- } ) . not . toThrow ( ) ;
10518
+ inject ( function ( myComponentDirective ) {
10519
+ expect ( myComponentDirective [ 0 ] ) . toEqual ( jasmine . objectContaining ( {
10520
+ $customAnnotation : 'XXX'
10521
+ } ) ) ;
10522
+ } ) ;
10521
10523
} ) ;
10522
10524
10523
10525
it ( 'should return ddo with reasonable defaults' , function ( ) {
You can’t perform that action at this time.
0 commit comments