File tree 2 files changed +14
-11
lines changed
2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -968,8 +968,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
968
968
* See {@link ng.$compile#-bindtocontroller- `bindToController`}.
969
969
* - `transclude` – `{boolean=}` – whether {@link $compile#transclusion content transclusion} is enabled.
970
970
* Disabled by default.
971
- * - `$canActivate` – `{function()=}` – TBD.
972
- * - `$routeConfig` – `{object=}` – TBD.
971
+ * - `$...` – `{function()=}` – additional annotations to provide to the directive factory function.
973
972
*
974
973
* @returns {ng.$compileProvider } the compile provider itself, for chaining of function calls.
975
974
* @description
@@ -1080,12 +1079,14 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1080
1079
} ;
1081
1080
}
1082
1081
1083
- if ( options . $canActivate ) {
1084
- factory . $canActivate = options . $canActivate ;
1085
- }
1086
- if ( options . $routeConfig ) {
1087
- factory . $routeConfig = options . $routeConfig ;
1088
- }
1082
+ // Copy any annotation properties (starting with $) over to the factory function
1083
+ // These could be used by libraries such as the new component router
1084
+ forEach ( options , function ( val , key ) {
1085
+ if ( key . charAt ( 0 ) === '$' ) {
1086
+ factory [ key ] = val ;
1087
+ }
1088
+ } ) ;
1089
+
1089
1090
factory . $inject = [ '$injector' ] ;
1090
1091
1091
1092
return this . directive ( name , factory ) ;
Original file line number Diff line number Diff line change @@ -9321,14 +9321,16 @@ describe('$compile', function() {
9321
9321
} ) ;
9322
9322
} ) ;
9323
9323
9324
- it ( 'should add router annotations to directive factory' , function ( ) {
9324
+ it ( 'should add additional annotations to directive factory' , function ( ) {
9325
9325
var myModule = angular . module ( 'my' , [ ] ) . component ( 'myComponent' , {
9326
9326
$canActivate : 'canActivate' ,
9327
- $routeConfig : 'routeConfig'
9327
+ $routeConfig : 'routeConfig' ,
9328
+ $customAnnotation : 'XXX'
9328
9329
} ) ;
9329
9330
expect ( myModule . _invokeQueue . pop ( ) . pop ( ) [ 1 ] ) . toEqual ( jasmine . objectContaining ( {
9330
9331
$canActivate : 'canActivate' ,
9331
- $routeConfig : 'routeConfig'
9332
+ $routeConfig : 'routeConfig' ,
9333
+ $customAnnotation : 'XXX'
9332
9334
} ) ) ;
9333
9335
} ) ;
9334
9336
You can’t perform that action at this time.
0 commit comments