This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -1030,7 +1030,8 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1030
1030
* See {@link ng.$compile#-bindtocontroller- `bindToController`}.
1031
1031
* - `transclude` – `{boolean=}` – whether {@link $compile#transclusion content transclusion} is enabled.
1032
1032
* Disabled by default.
1033
- * - `$...` – `{function()=}` – additional annotations to provide to the directive factory function.
1033
+ * - `$...` – additional properties to attach to the directive factory function and the controller
1034
+ * constructor function. (This is used by the component router to annotate)
1034
1035
*
1035
1036
* @returns {ng.$compileProvider } the compile provider itself, for chaining of function calls.
1036
1037
* @description
@@ -1106,6 +1107,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1106
1107
forEach ( options , function ( val , key ) {
1107
1108
if ( key . charAt ( 0 ) === '$' ) {
1108
1109
factory [ key ] = val ;
1110
+ controller [ key ] = val ;
1109
1111
}
1110
1112
} ) ;
1111
1113
Original file line number Diff line number Diff line change @@ -10044,6 +10044,22 @@ describe('$compile', function() {
10044
10044
} ) ) ;
10045
10045
} ) ;
10046
10046
10047
+ it ( 'should add additional annotations to the controller constructor' , function ( ) {
10048
+ var myModule = angular . module ( 'my' , [ ] ) . component ( 'myComponent' , {
10049
+ $canActivate : 'canActivate' ,
10050
+ $routeConfig : 'routeConfig' ,
10051
+ $customAnnotation : 'XXX'
10052
+ } ) ;
10053
+ module ( 'my' ) ;
10054
+ inject ( function ( myComponentDirective ) {
10055
+ expect ( myComponentDirective [ 0 ] . controller ) . toEqual ( jasmine . objectContaining ( {
10056
+ $canActivate : 'canActivate' ,
10057
+ $routeConfig : 'routeConfig' ,
10058
+ $customAnnotation : 'XXX'
10059
+ } ) ) ;
10060
+ } ) ;
10061
+ } ) ;
10062
+
10047
10063
it ( 'should return ddo with reasonable defaults' , function ( ) {
10048
10064
angular . module ( 'my' , [ ] ) . component ( 'myComponent' , { } ) ;
10049
10065
module ( 'my' ) ;
You can’t perform that action at this time.
0 commit comments