@@ -52,8 +52,8 @@ SUBMITTED_CLASS = 'ng-submitted';
52
52
*
53
53
*/
54
54
//asks for $scope to fool the BC controller module
55
- FormController . $inject = [ '$element' , '$attrs' , '$scope' , '$animate' ] ;
56
- function FormController ( element , attrs , $scope , $animate ) {
55
+ FormController . $inject = [ '$element' , '$attrs' , '$scope' , '$animate' , '$interpolate' ] ;
56
+ function FormController ( element , attrs , $scope , $animate , $interpolate ) {
57
57
var form = this ,
58
58
parentForm = element . parent ( ) . controller ( 'form' ) || nullFormCtrl ,
59
59
controls = [ ] ;
@@ -62,7 +62,7 @@ function FormController(element, attrs, $scope, $animate) {
62
62
form . $error = { } ;
63
63
form . $$success = { } ;
64
64
form . $pending = undefined ;
65
- form . $name = attrs . name || attrs . ngForm ;
65
+ form . $name = $interpolate ( attrs . name || attrs . ngForm || '' ) ( $scope ) ;
66
66
form . $dirty = false ;
67
67
form . $pristine = true ;
68
68
form . $valid = true ;
@@ -467,9 +467,21 @@ var formDirectiveFactory = function(isNgForm) {
467
467
468
468
var parentFormCtrl = formElement . parent ( ) . controller ( 'form' ) ,
469
469
alias = attr . name || attr . ngForm ;
470
+ var unobserveName = noop ;
470
471
471
472
if ( alias ) {
472
473
setter ( scope , alias , controller , alias ) ;
474
+ unobserveName = attr . $observe ( attr . name ? 'name' : 'ngForm' , function ( newValue ) {
475
+ if ( alias === newValue ) return ;
476
+ setter ( scope , alias , undefined , alias ) ;
477
+ alias = newValue ;
478
+ setter ( scope , alias , controller , alias ) ;
479
+ if ( parentFormCtrl ) {
480
+ parentFormCtrl . $$renameControl ( controller , alias ) ;
481
+ } else {
482
+ controller . $name = alias ;
483
+ }
484
+ } ) ;
473
485
}
474
486
if ( parentFormCtrl ) {
475
487
formElement . on ( '$destroy' , function ( ) {
0 commit comments