@@ -1511,8 +1511,14 @@ var nameToControllerMap = {};
1511
1511
* log a message if the controller is instantiated on the window
1512
1512
*/
1513
1513
angular . module ( 'ngHintControllers' , [ ] ) .
1514
- config ( [ '$provide' , function ( $provide ) {
1514
+ config ( [ '$provide' , '$controllerProvider' , function ( $provide , $controllerProvider ) {
1515
1515
$provide . decorator ( '$controller' , [ '$delegate' , controllerDecorator ] ) ;
1516
+
1517
+ var originalRegister = $controllerProvider . register ;
1518
+ $controllerProvider . register = function ( name , constructor ) {
1519
+ stringOrObjectRegister ( name ) ;
1520
+ originalRegister . apply ( $controllerProvider , arguments ) ;
1521
+ }
1516
1522
} ] ) ;
1517
1523
1518
1524
function controllerDecorator ( $delegate ) {
@@ -1521,7 +1527,10 @@ function controllerDecorator($delegate) {
1521
1527
var match = ctrl . match ( CNTRL_REG ) ;
1522
1528
var ctrlName = ( match && match [ 1 ] ) || ctrl ;
1523
1529
1524
- sendMessageForControllerName ( ctrlName ) ;
1530
+ if ( ! nameToControllerMap [ ctrlName ] ) {
1531
+ sendMessageForControllerName ( ctrlName ) ;
1532
+ }
1533
+
1525
1534
if ( ! nameToControllerMap [ ctrlName ] && typeof window [ ctrlName ] === 'function' ) {
1526
1535
sendMessageForGlobalController ( ctrlName ) ;
1527
1536
}
@@ -1537,6 +1546,14 @@ function controllerDecorator($delegate) {
1537
1546
*/
1538
1547
var originalModule = angular . module ;
1539
1548
1549
+ function stringOrObjectRegister ( controllerName ) {
1550
+ if ( ( controllerName !== null ) && ( typeof controllerName === 'object' ) ) {
1551
+ Object . keys ( controllerName ) . forEach ( processController ) ;
1552
+ } else {
1553
+ processController ( controllerName ) ;
1554
+ }
1555
+ }
1556
+
1540
1557
function processController ( ctrlName ) {
1541
1558
nameToControllerMap [ ctrlName ] = true ;
1542
1559
sendMessageForControllerName ( ctrlName ) ;
@@ -1594,11 +1611,7 @@ angular.module = function() {
1594
1611
originalController = module . controller ;
1595
1612
1596
1613
module . controller = function ( controllerName , controllerConstructor ) {
1597
- if ( ( controllerName !== null ) && ( typeof controllerName === 'object' ) ) {
1598
- Object . keys ( controllerName ) . forEach ( processController ) ;
1599
- } else {
1600
- processController ( controllerName ) ;
1601
- }
1614
+ stringOrObjectRegister ( controllerName ) ;
1602
1615
return originalController . apply ( this , arguments ) ;
1603
1616
} ;
1604
1617
@@ -1715,10 +1728,15 @@ angular.module = function(name, requiresOriginal) {
1715
1728
1716
1729
module . requiresOriginal = requiresOriginal ;
1717
1730
modules [ name ] = module ;
1718
- hasNameSpace ( name ) ;
1719
1731
var modToCheck = getModule ( name , true ) ;
1732
+ //check arguments to determine if called as setter or getter
1733
+ var modIsSetter = arguments . length > 1 ;
1734
+
1735
+ if ( modIsSetter ) {
1736
+ hasNameSpace ( name ) ;
1737
+ }
1720
1738
1721
- if ( modToCheck && modToCheck . requiresOriginal !== module . requiresOriginal ) {
1739
+ if ( modToCheck && modToCheck . requiresOriginal !== module . requiresOriginal && modIsSetter ) {
1722
1740
if ( ! modData . createdMulti [ name ] ) {
1723
1741
modData . createdMulti [ name ] = [ getModule ( name , true ) ] ;
1724
1742
}
0 commit comments