This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Expand file tree Collapse file tree 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) {
968968 * See {@link ng.$compile#-bindtocontroller- `bindToController`}.
969969 * - `transclude` – `{boolean=}` – whether {@link $compile#transclusion content transclusion} is enabled.
970970 * Disabled by default.
971- * - `$canActivate` – `{function()=}` – TBD.
972- * - `$routeConfig` – `{object=}` – TBD.
971+ * - `$...` – `{function()=}` – additional annotations to provide to the directive factory function.
973972 *
974973 * @returns {ng.$compileProvider } the compile provider itself, for chaining of function calls.
975974 * @description
@@ -1080,12 +1079,14 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
10801079 } ;
10811080 }
10821081
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+
10891090 factory . $inject = [ '$injector' ] ;
10901091
10911092 return this . directive ( name , factory ) ;
Original file line number Diff line number Diff line change @@ -9321,14 +9321,16 @@ describe('$compile', function() {
93219321 } ) ;
93229322 } ) ;
93239323
9324- it ( 'should add router annotations to directive factory' , function ( ) {
9324+ it ( 'should add additional annotations to directive factory' , function ( ) {
93259325 var myModule = angular . module ( 'my' , [ ] ) . component ( 'myComponent' , {
93269326 $canActivate : 'canActivate' ,
9327- $routeConfig : 'routeConfig'
9327+ $routeConfig : 'routeConfig' ,
9328+ $customAnnotation : 'XXX'
93289329 } ) ;
93299330 expect ( myModule . _invokeQueue . pop ( ) . pop ( ) [ 1 ] ) . toEqual ( jasmine . objectContaining ( {
93309331 $canActivate : 'canActivate' ,
9331- $routeConfig : 'routeConfig'
9332+ $routeConfig : 'routeConfig' ,
9333+ $customAnnotation : 'XXX'
93329334 } ) ) ;
93339335 } ) ;
93349336
You can’t perform that action at this time.
0 commit comments