diff --git a/src/ng/directive/form.js b/src/ng/directive/form.js index 0cd70844ee72..5ea5d0190be8 100644 --- a/src/ng/directive/form.js +++ b/src/ng/directive/form.js @@ -46,8 +46,8 @@ var nullFormCtrl = { * */ //asks for $scope to fool the BC controller module -FormController.$inject = ['$element', '$attrs', '$scope']; -function FormController(element, attrs) { +FormController.$inject = ['$element', '$attrs', '$scope', '$interpolate']; +function FormController(element, attrs, $scope, $interpolate) { var form = this, parentForm = element.parent().controller('form') || nullFormCtrl, invalidCount = 0, // used to easily determine if we are valid @@ -55,7 +55,7 @@ function FormController(element, attrs) { controls = []; // init state - form.$name = attrs.name || attrs.ngForm; + form.$name = $interpolate(attrs.name || attrs.ngForm || '', false)($scope); form.$dirty = false; form.$pristine = true; form.$valid = true; diff --git a/test/ng/directive/formSpec.js b/test/ng/directive/formSpec.js index 77beb2fd64ef..3217f82094a2 100644 --- a/test/ng/directive/formSpec.js +++ b/test/ng/directive/formSpec.js @@ -95,6 +95,24 @@ describe('form', function() { expect(scope.obj.myForm).toBeTruthy(); }); + it('should support a template as form name', function() { + scope.data = [ 'first', 'second' ]; + doc = $compile( + '
' + + '
' + +// '
' + + '
')(scope); + + scope.$apply(); + + expect(scope.myForm).toBeDefined(); + expect(scope.myForm.children_0).toBeDefined(); + expect(scope.myForm.children_1).toBeDefined(); +// expect(scope.myForm.children).toBeDefined(); +// expect(scope.myForm.children[0]).toBeDefined(); +// expect(scope.myForm.children[1]).toBeDefined(); + }) + it('should support two forms on a single scope', function() { doc = $compile(